char testChar = 'a';
char myCharString[] = "asd";
char *pointerToFirstChar = &(myCharString[0]);
char *pointerToSecondChar = &(myCharString[1]);
cout << "A char takes " << sizeof(testChar) << " byte(s)";
cout << "Value was " << pointerToFirstChar << ", address: " << &pointerToFirstChar << endl;
cout << "Value 2 was " << pointerToSecondChar << ", address:" << &pointerToSecondChar << endl;
「A字符需要1個字節」
」 ...地址:00F3F718"
「...地址:00F3F70C」,
我想地址之間的差異應該是1個字節,因爲這將是分離它們的數據的大小。爲什麼不是這樣?
你把指針的地址。 – user2357112