Hello World Error
May 7, 2010 at 6:18am UTC
Hello, I'm new to C++ and am beginning to learn it by reading "Sams Teach Yourself In One Hour A Day (6th Edition)". I'm using Bloodsheds Dev-C++ as the compiler and am having difficulties compiling the Hello World code from the book.
For some reason it gives me an error on the 5th line ( std::co...)
C++ Code:
1 2 3 4 5 6 7
#include <iostream>
int main()
{
std::cout << “Hello World!\n”;
return 0;
}
Thx 4 Reading.
May 7, 2010 at 6:45am UTC
std::cout << "Hello World!\n" ;
Last edited on May 7, 2010 at 6:45am UTC
May 7, 2010 at 8:06am UTC
Denis is right. There is something weird about your
" "
You may wanna try the following as well. i.e. Try using namespace..
1 2 3 4 5 6 7 8 9
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!\n" ;
return 0;
}
May 7, 2010 at 12:38pm UTC
Make sure you are using a plain-text editor (like Notepad or Emacs), and not your favorite word processor (like Word or Writer).
May 7, 2010 at 5:20pm UTC
Ahh I see. It's probably because I copy/pasted the code from an ebook into the compiler. Can't believe I didn't notice that. Well thanks, that helped.
May 7, 2010 at 10:28pm UTC
Yeah, those stupid "smart quotes" get people all the time.
Topic archived. No new replies allowed.