Archived

This topic is now archived and is closed to further replies.

Guest Anonymous Poster

whats wrong with this c++ code?

This topic is 6562 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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


Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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;
}
/*---------------------------------------*/

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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

Share this post


Link to post
Share on other sites