Feb 10, 2014 at 1:53pm UTC
I have wrote the following code yet when I compile it, i fail to get the desired outcome.
#include <iostream>
using namespace std ;
\\ A C++Program to output a greeting.
int main()
{
cout << "Hello World!" << endl ;
return 0;
}
After inputting c:\MyPrograms>c++ hell.cpp in to command prompt and get ->
hello.cpp:5:1 error: stray '\' in program
\\ A C++Program to output a greeting.
^
Any help would be appreciated.
-MnxBUCKethead
Feb 10, 2014 at 2:02pm UTC
Your comment is the following:
\\ A C++Program to output a gretting.
Comments should be done as follows:
// A C++Program to output a gretting.
Feb 10, 2014 at 2:15pm UTC
and you can delete his endl here:
cout << "Hello World!" << endl ;
and write it like that:
cout << "hello world!" ;
Feb 10, 2014 at 2:21pm UTC
kugi wrote:and you can delete his endl here:
cout << "Hello World!" << endl ;
and write it like that:
cout << "hello world!" ;
You could, but there's nothing wrong with having that endline there. It's not causing any problems, and it's certainly not responsible for the OP's compilation issues.
EDIT: And both you and the OP should learn to use code tags when posting here:
http://www.cplusplus.com/articles/z13hAqkS/
Last edited on Feb 10, 2014 at 2:22pm UTC