Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Having trouble with program.

Status
Not open for further replies.

oxfitguy

Instructor
Mar 18, 2006
1
0
0
US
# include <iostream>

using std: :cout;
using std: :cin;
using std: :endl;

void mystery1(char *, const char*); //prototype

int main ()
{
char string1 [80];
char string2 [80];

cout << "Enter two strings:";
cin >> string1 >> string2;
mystery1 (string1, string2);
cout << string1 << endl;

return 0;

} //end main

Why will this program not compile and execute?
 
It would help if you told us the compile errors you're getting, but just by looking at the code you gave, here's what I found:
Code:
using std: :cout;
using std: :cin;
using std: :endl;
The compiler is usually pretty oblivious to white space, but in this case I'm sure it wouldn't know that std: :cout is really std::cout.

:: is a special operator in C++ that is different than the : operator, so if you put a space in the middle of : : it won't understand which operator you're talking about.

Other than that, you should get a link error about there being a prototype for mystery1(), but no function body defined for it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top