[dywang@deyu zzz]$ vim hello.c
[dywang@deyu zzz]$ cat hello.c
#include <stdio.h>
int main() {
printf("Hello!\n");
)
) 前面,應該要有對應的 (。
[dywang@deyu zzz]$ gcc hello.c hello.c: In function ‘main’: hello.c:4:1: error: expected statement before ‘)’ token ) ^ hello.c:4:1: error: expected declaration or statement at end of input
[dywang@deyu zzz]$ vim hello.c
[dywang@deyu zzz]$ cat hello.c
#include <stdio.h>
int main() {
printf("Hello!\n");
}
[dywang@deyu zzz]$ gcc hello.c [dywang@deyu zzz]$
[dywang@deyu zzz]$ vim debug1.c
[dywang@deyu zzz]$ cat debug1.c
#include <stdio.h>
int main() {
int a=1, b=2, c;
c = a-b;
printf("1 + 2 = %d\n", c);
}
[dywang@deyu zzz]$ gcc -o debug1 debug1.c
1 + 2 = -1,與預期結果不同。由於語意錯誤不會造成編譯錯誤,除錯上較困難,程式設計師要設定除錯點逐步檢查程式內容。
[dywang@deyu zzz]$ ./debug1 1 + 2 = -1