Compiler Errors
Read the Compiler ErrorsMessages like : tell you where to look.linux3[77] % gcc -Wall -ansi sample.c sample.c: In function `main': sample.c:30: parse error before `printf' sample.c:36: warning: control reaches end of non-void function linux3[78] % Here are the lines of sample.c from line 26 to 36 :
The first error :
Says before the word printf on line 30 there was a parse error. Since printf is the first word on line 30, you need to examine the previous line. Sure enough there is a missing semicolon on line 29.sample.c:30: parse error before `printf' There is also a warning message: Line 36 is the closing brace of main and the warning means that something needs to be returned instead of the function just ending. Adding return 0; will fix this problem.sample.c:36: warning: control reaches end of non-void function Instead of cutting or commenting out every line that comes up with an error, it's important to try to understand what's causing that error. But How Do I Get My Editor To Tell Me What Line Number I'm On?In xemacs, the command [ESC]-x line (press escape, press x, then type the word line and hit enter) will turn on the line numbering. The line you're on will appear on the bottom bar. Like this : To jump to a line, the command [ESC]-x goto line (press escape, press x, then type the two words goto line and hit enter) will prompt you for the line number you want to go to. Then type in the line number and hit enter.ISO8--**-XEmacs: sample.c (C Font)----L30--All---------------- Alternatively, you can invoke the next line (^N) command with an argument, for example
goes down 25 lines. In vi, the command [CTRL]->g (hold down the control key while pressing "g") will show you what line you are on. To jump to a line, type in the line number and then press "G".
CSEE | 201 | 201 S'05 | lectures | news | resources | help |
|