whats wrong with this c++ code?

Started by
8 comments, last by GameDev.net 24 years, 3 months ago
YOu need to call a pointer
Advertisement
Not sure what you mean by "calling a pointer". Assuming you have "included" the proper files, you should check your use of qoutation marks.----ie-

int WinMain()
{

int x = 500;

cout << "Something something" << x << "something else " << endl;


If you missed this accidently, sorry. I do it a lot on this board. You don't need a pointer for this simple 'cout' exercise though.

------------------
Still Learning...

Still Learning...
OH, now I see what you meant. Not sure what the "&x" is for. Your "cout" will show the value of "X" with the simple cout << x <<;
You have no reference for &X.

Still Learning...
If you've created an win32 consol app, you shouldn't get any problems. It worked for me.
In the tutorial I read it said that if you put an ampersand in front of a variable name it will represent the memory addresss of the variable not the contents and I was trying to print the contents of the variable followed by its memory address. i am doing this in a simple win32 console app and it wont work. What is wrong?
thanx in advance and HAPPY NEW YEAR
CoOlGuY


Sorry actually what you have should work...ALl you need is to make sure you include and make sure your using a win32 console app. It works fine for me
Why don't you tell us what error the compiler is giving??

Regards

Starfall

In VC++6 their is a small window at the bottom of the screen when you perform builds that indicates the progress. Whenever I try to build the app it attempts to compile the program and when its done it says errors: 1
warnings: 0
I am trying to build this sample program and vc++6 keeps telling me that their is one error and I can't find it. The program is supposed to return the value of the variable x and its memory address. Here is the code:

/* -example-[memory address of x']------ */

#include

int main()
{
int x = 654;

cout << "The value of 'x' is " << x << ", its memory address is "
<< &x << endl;

return 0;
}
/*---------------------------------------*/

Don't worry guys I got it to work. But thanx alot for all the help, couldn't have done it without ya
All The Best

This topic is closed to new replies.

Advertisement