Mooophy / Cpp-Primer

C++ Primer 5 answers
Creative Commons Zero v1.0 Universal
8.11k stars 3k forks source link

the second anwser in 4.29 #755

Open woshiZS opened 4 years ago

woshiZS commented 4 years ago

I have written the according code, it shows 1 when cout <<sizeof(p)/sizeof(*p)<<endl;. My os is windows , IDE is visual studio 2019 . Does the word undefined in your anwser means the output depends on the compiler or what?

TheLuckBird commented 1 year ago

cout << sizeof(int ) << endl; int i[10],p=i; cout << (sizeof(i)/sizeof(i)); cout << endl; cout << (sizeof(p)/sizeof(p));

my result is 2!