Web lists-archives.com

[Mingw-users] MinGW syntax error near unexpected token '('




Hi there,

I have been learning C for the past month now and I have managed to set up a
local environment to compile and execute basic programs as I go along with
the C tutorial I am following. Everything was working fine until yesterday.
Suddenly, for a reason unknown to me, the compiler started to give me the
following error:
< --------------------------------------

./hello.c: line 3: syntax error near unexpected token '('
./hello.c: line 3: 'int main ()'

-------------------------------------- >

The file hello.c contains basic code to print "Hello World!" in the command
prompt window. The code is pasted below for your reference:

< --------------------------------------

#include <stdio.h>

int main()
{
/* Print "Hello World" on screen */
printf("Hello, World!\n");

 return 0; 
}

-------------------------------------- >

As you can see there is nothing wrong with the code. So for some reason,
something went wrong with MinGW i think. I have done a search on Google and
ended up at  this post on Stack Exchange
<http://stackoverflow.com/questions/17585748/unexpected-syntax-error-from-mingw-compiling-a-simple-c-program>  
but I did not find a solution there either. One person there suggested the
use of Dev-C++ which I downloaded and installed but I have no clue what to
do with it. 

I am using the Windows 8 OS and have installed MinGW and MSYS. When I open
MSYS, it opens the command prompt window with MinGW32 in the window title. I
then type 'cd /mysources' which takes me to the required directory and the I
type 'gcc hello.c -o hello' and then the program is compiled. I then type
'hello' and press enter which executes the hello.exe and should print "Hello
World!" in the command prompt window.

Could anyone assist me in any way with this problem?

Thanks in advance!



--
View this message in context: http://mingw-users.1079350.n2.nabble.com/MinGW-syntax-error-near-unexpected-token-tp7583761.html
Sent from the MinGW-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
_______________________________________________
MinGW-users mailing list
MinGW-users@xxxxxxxxxxxxxxxxxxxxx

This list observes the Etiquette found at 
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe