Odd Error: invalid operands
I'm getting a strange error with this program. I'm learning about pointers, and for some reason, it isn't letting me output a pointer on line 23.
pointers1.cpp:23: error: invalid operands of types ‘const char [20]’ and ‘int*’ to binary ‘operator*’
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
#include <iostream>
using std::cout; //std::cout
int main()
{
int applesauce; //variable
int * point_applesauce=NULL; //pointer
applesauce = 5; //set val of var
point_applesauce = &applesauce; //assign address of applesauce to point_applesauce
cout << "applesauce: " << applesauce << '\n';
cout << "*point_applesauce" << *point_applesauce << "\n\n";
cout << "*point_applesauce = 7\n";
*point_applesauce = 7; //set applesauce to 7
cout << "*point_applesauce: " << *point_applesauce << '\n';
cout << "applesauce: " << applesauce << "\n\n";
cout << "applesauce = 9" << '\n';
applesauce = 9;
cout << "applesauce: " << applesauce << '\n';
cout << "*point_applesauce: " << *point_applesauce << '\n'; //23
return 0;
}
| |
Compiles and runs fine here. There's no problem with that code.
It must be something with me using Linux(Unbuntu)...I have the latest version.
Nope, I'm on ubuntu here and it works fine. Try again.
EDIT: it also works on wxdev-c++ under wine.
Last edited on
Topic archived. No new replies allowed.