+ 5
No Output! Why?
Why these codes have no output?! #include <iostream> using namespace std; int main() { int score = 5; int *add; *add= score; cout << &score << endl; cout << *add<< endl<< add << endl<<*&score; delete &score; return 0; }
5 Answers
+ 4
@lucasfid telegram id
+ 3
#include <iostream>
using namespace std;
int main()
{
int score = 5;
int *add;
add= new int(score);
cout << &score << endl;
cout << *add<< endl<< add << endl<<*&score;
delete add;
return 0;
}
+ 1
you have forgotten & symbol before score in
*add= score;
which means you're trying to allocate a memory address explicitly, to be 5. and I don't think there will be any memory block with this unique address(at least, I don't know). make it into *add = &score;
+ 1
its obvious that you made a mistake by use a int poiner without initial it.
0
Tip:Obvious that you created a int pointer without initial it.