+ 4
why the last cout has no output?
The fourth cout in program below has no output while the three other do. And if you remove the first command (int i =1) just the first cout has output. Please reply if you know why. int i = 1; int *p1; cout <<"1. "<< p1 <<" "<< *p1 << endl; *p1 = 1; cout <<"2. "<< p1 <<" "<< *p1 << endl; int *p2; cout <<"3. "<< p2 <<" "<< *p2 << endl; *p2 = 1; cout <<"4. "<< p2 <<" "<< *p2 << endl; the same code in playground👇 https://code.sololearn.com/cy8yoFGO0NFq/?ref=app
2 ответов
+ 8
dare say kurwius is correct. If you set int *p2 = p1; the code runs correctly