+ 1

Can you explain what is wrong with this code?

#include <iostream> using namespace std; int main() { int a=1; int b,c; b=&a; c=*b; cout<<c; return 0; }

18th Aug 2019, 6:59 AM
Tom
Tom - avatar
3 Respostas
+ 3
b should be declared as a pointer too #include <iostream> using namespace std; int main() { int a=1; int *b,c; b=&a; c=*b; cout<<c; return 0 } this will output 1....
18th Aug 2019, 8:33 AM
Aditya
Aditya - avatar
+ 1
I think, U want to copy content of a to c using b as pointer. See my commented code. Hope this helps...!!! #include <iostream> using namespace std; int main() { int a=1; int b,c;// int a, *b; b=&a; c=*b; cout<<c; return 0; }
18th Aug 2019, 8:47 AM
Kuri
Kuri - avatar
0
Is there a syntax error or what do you want to know?:)
18th Aug 2019, 7:03 AM
Tom Hammerbacher
Tom Hammerbacher - avatar