tags:

views:

622

answers:

2

I have a problem running a simple Hello-world program in C++ on my Windows XP. I have written a post here:

Using the g++ C++ compiler from cygwin

where I stated the problem and I received many helpful replies, which solved some things. However, I still cannot run my hello-world program. Please, have a look at the post, I have included the program there. A friend of mine is able to run this program on his machine without problems. So, the problem should be in my system or libraries or something else, but I cannot figure what. In the "Edited" section of my post, I have included what error messages exactly I get.

Here is what I receive when I try to compile the program like this:

g++ hello.cpp

From the cygwin shell:

When I try g++ hello.cpp, I get:

hello.cpp:1: parse error before character 0357
hello.cpp: In function 'int main()':
hello.cpp:'cout' undeclared (first use this function)
hello.cpp: (Each undeclared identifier is reported only once
hello.cpp: for each function it appears in.)
hello.cpp: 'endl' undeclared (first use this function)
g++.exe: hello.cpp: No such file or directory
g++.exe: No input files
g++.exe: hello.cpp: No such file or directory
g++.exe: No input files
g++.exe: hello.cpp: No such file or directory
g++.exe: No input files
g++.exe: hello.cpp: No such file or directory
g++.exe: No input files
g++.exe: hello.cpp: No such file or directory
g++.exe: No input files

And here is what I get when I try to compile the program (again with g++ hello.cpp) from the DOS command prompt:

When I try g++ hello.cpp, I get:

hello.cpp:1: parse error before character 0357
hello.cpp: In function 'int main()':
hello.cpp:'cout' undeclared (first use this function)
hello.cpp: (Each undeclared identifier is reported only once
hello.cpp: for each function it appears in.)
hello.cpp: 'endl' undeclared (first use this function)
+2  A: 

You have an illegal character in your code; it may be caused by a bad character encoding or something like that. Try to check that.

jpalecek
+2  A: 

Hello again. It looks like you have somehow got an illegal character in your code. Did you type the code in yourself or copy & paste it? If the latter, the source you copied from may be suspect in some way - type the code into the editor yourself, save it and recompile.

anon