GIDForums

Go Back   GIDForums > Computer Programming Forums > CPP / C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 21-Mar-2008, 09:35
supes69 supes69 is offline
New Member
 
Join Date: Mar 2008
Posts: 4
supes69 is on a distinguished road

Error Codes using Visual Studio 2005


ok this is my first time posting and I am just starting to learn C++. I am using Visual Studio 2005 to build my programs and the program is right out of chapter one of the Deitel and Deitel book. this is the code that im using.

CPP / C++ / C Code:
#include <iostream>
using namespace std;

int main()
{

	int num1, num2; 
	
	cout << "Enter two intergers, and I will tell you\n"
	     << "the relationships they satisfy: ";
	
	cin >> num1 >> num2;

	if (num1 == num2)
		cout << num1 << "is equal to " << num2 << endl;

	if (num1 != num2)
		cout << num1 << "is not equal to " << num2 << endl;

	if (num1 < num2)
		cout << num1 << "is less than " << num2 << endl;

	if (num1 <= num2)
		cout << num1 << "is less than or equal to " num2 << endl;

	if (num1 > num2) 
		cout << num1 << "is greater than " << num2 << endl;

	if (num1 >= num2) 
		cout << num1 << "is greater than or equal to " << num2 << endl;

	return 0;			

}
and these are the three errors I'm getting.
Code:
error C2146: syntax error : missing ';' before identifier 'num2' error C2563: mismatch in formal parameter list error C2568: '<<' : unable to resolve function overload

is this just something that VS.net does not understand or have I totally messed something up?

thanks for any help in advance!
Last edited by admin : 21-Mar-2008 at 09:59. Reason: Please insert your example C/C++ codes between [CPP] and [/CPP] tags
  #2  
Old 21-Mar-2008, 09:47
fakepoo fakepoo is offline
Regular Member
 
Join Date: Oct 2007
Posts: 395
fakepoo is a jewel in the roughfakepoo is a jewel in the roughfakepoo is a jewel in the rough

Re: Error Codes using Visual Studio 2005


Do you see anything wrong here?
CPP / C++ / C Code:
if (num1 <= num2)
cout << num1 << "is less than or equal to " num2 << endl;

The first thing you should do when looking at an error message is look at the line that it refers to.

error C2146: syntax error : missing ';' before identifier 'num2' refers to line 2146 which I am guessing is the line above. You are missing a "<<" before num2.

The best thing to do is to fix the first error, then recompile. This will oftentimes fix more than one error.
  #3  
Old 21-Mar-2008, 09:51
supes69 supes69 is offline
New Member
 
Join Date: Mar 2008
Posts: 4
supes69 is on a distinguished road
Smile

Re: Error Codes using Visual Studio 2005


you are awesome. thanks for the help!!!!! I must have went through that code 300 times and never once did i see that.
 

Recent GIDBlogUpdates On The All New Toyota VIOS - Part III by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to read an argument from the terminal in visual c++ studio swedenguy MS Visual C++ / MFC Forum 1 20-Nov-2007 15:32
Multiple questions for C++ project devster420 CPP / C++ Forum 1 20-Apr-2007 21:26
Major newbie problem cynack MS Visual C++ / MFC Forum 1 08-Apr-2007 11:25
can i run visual 2005 mfc project in visual 6 or 2003? spillover MS Visual C++ / MFC Forum 1 27-Dec-2006 18:09
How Visual C++ only from Visual Studio .net Picstudent .NET Forum 2 28-May-2006 20:52

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 09:51.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.