Friday, May 21, 2010

How do I do this C programming???

I'm trying this "hello world" program and every time I compile the SC, this error message appears:


C:\Program Files\Miracle C\hello.c: line 1: Parse Error, expecting `SEP'


'1: include %26lt;stdio.h%26gt; 2: 3: int radius, area'


aborting compile

How do I do this C programming???
since you didnt show your code, the only thing I see is "include %26lt;stdio.h%26gt;" should be #include %26lt;stdio.h%26gt;, and int radius, area should be int radius, area;. Other than that, who knows without seeing the code you wrote.
Reply:post the source code
Reply:I think there are two booboos here. Try :





#include %26lt;stdio.h%26gt; /* No ; after the lines with a # */





int radius, area; /* Must have ; after normal lines of C */





This is true because the first line is a line intended for the C preprocessor. The second line is a line of standard C code, declaration of two integers named radius and area, to be specific.





I hope this will help you out with the general format.
Reply:All preprocessor directives start with #


That is, instead of


include %26lt;stdio.h%26gt;


mut be:


#include %26lt;stdio.h%26gt;
Reply:The error message is specific to the compiler you're using: Miracle C (http://www.c-compiler.com/guide/errmessp... ). To put is simple, expecting a SEP means the compiler expects you to put a semicolon in a place that you don't put a semicolon in.





AFAIK, preprocessor functions isn't ended with a semicolons, so your code should actually compile correctly.





My guess is, perhaps your DOS environment doesn't recognize the symbol #, so it passes the # symbol as nothing, and this makes Miracle interpret it as a normal C functions. The reason for this is: the error message states "1: include ... " %26lt; the # doesn't appear on this message, while you actually have a # in the source code.
Reply:Which compiler are you using ,programming an hello world in c program is the easiest one .


In Linux , open a text file using vi editor and type your program , save it using wq! , and type gcc %26lt; program name%26gt; . this will create a.out , run that , if any args needed from command line. For other os , search in google.


No comments:

Post a Comment