Need help, errors messages added as comments after line.
#include <iostream>
int Add (int x, int y)
{
cout << "In Add(), received " << x << " and " << y << "\n"; //Error C2065: 'cout' : undeclared identifier
return (x+y);
}
int main()
using namespace std; //Error C2143: syntax error : missing ';' before 'using'
{ //Error C2447: '{' : missing function header
cout << "I'm in main()!\n";
int a, b, c;
cout << "Enter two numbers: ";
cin >> a;
cin >> b;
cout << "\nCalling Add()\n";
c=Add(a,b);
cout << "\nBack in main().\n";
cout << "c was set to " << c;
cout << "\nExiting...\n\n";
return 0;
-------------------------------------------------------
Another question,
What is code tags and how do use them?
Last edited by Fnyx; October 26th, 2010 at 06:11 AM.
Reason: Code tags
First thing I see is that you are using cout in your Add function, but you haven't used the namespace yet.
Two ways to start is to change
Code:
int Add (int x, int y)
{
cout << "In Add(), received " << x << " and " << y << "\n"; //Error C2065: 'cout' : undeclared identifier
return (x+y);
}
to
Code:
int Add (int x, int y)
{
std::cout << "In Add(), received " << x << " and " << y << "\n"; //Error C2065: 'cout' : undeclared identifier
return (x+y);
}
or you can move
Code:
using namespace std; //Error C2143: syntax error : missing ';' before 'using'
just after the include
Code:
#include <iostream>
using namespace std; //Error C2143: syntax error : missing ';' before 'using'
Hope that helps.
Be sure to rate those who help!
-------------------------------------------------------------
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.