主题:为什么?
#include<stdio.h>
#include<stdlib.h>
int main(int argc,char *argv[])
{
int arg;
for(arg=0;arg<argc;arg++){
if(argv[arg][0] == '-')
printf("option:%s\n",argv[arg]+1);
else
printf("argument %d: %s\n",arg,argv[arg]);
}
exit(0);
}
和
[root@GZH gzh]# cat pad.c
#include<unistd.h>
#include<stdlib.h>
#include<curses.h>
int main()
{
WINDOW *pad_ptr;
int x,y;
int pad_lines;
int pad_cols;
char disp_char;
initscr();
pad_lines=LINES+50;
pad_cols=COLS+50;
pad_ptr=newpad(pad_lines,pad_cols);
disp_char='a';
for(x=0;x<pad_lines;i++){
for(y=0;y<pad_cols;y++){
mvaddch(pad_ptr,x,y,disp_char);
if(disp_char=='z')
disp_char='a';
else
disp_char++;
}
}
prefresh(pad_ptr,5,7,2,2,9,9);
sleep(1);
prefresh(pad_ptr,LINES+5,COLS+7,5,5,21,19);
sleep(1);
delwin(pad_ptr);
endwin();
exit(EXIT_SUCCESS);
}
[root@GZH gzh]# sh pad.c
pad.c: line 5: syntax error near unexpected token `('
pad.c: line 5: `int main()'
[root@GZH gzh]#
-----------------------------------------------------------------------------
所有的类似这样的c程序,都出现如下结果:
args.c: line 4: syntax error near unexpected token `('
args.c: line 4: `int main(int argc,char *argv[])'
为什么?
#include<stdlib.h>
int main(int argc,char *argv[])
{
int arg;
for(arg=0;arg<argc;arg++){
if(argv[arg][0] == '-')
printf("option:%s\n",argv[arg]+1);
else
printf("argument %d: %s\n",arg,argv[arg]);
}
exit(0);
}
和
[root@GZH gzh]# cat pad.c
#include<unistd.h>
#include<stdlib.h>
#include<curses.h>
int main()
{
WINDOW *pad_ptr;
int x,y;
int pad_lines;
int pad_cols;
char disp_char;
initscr();
pad_lines=LINES+50;
pad_cols=COLS+50;
pad_ptr=newpad(pad_lines,pad_cols);
disp_char='a';
for(x=0;x<pad_lines;i++){
for(y=0;y<pad_cols;y++){
mvaddch(pad_ptr,x,y,disp_char);
if(disp_char=='z')
disp_char='a';
else
disp_char++;
}
}
prefresh(pad_ptr,5,7,2,2,9,9);
sleep(1);
prefresh(pad_ptr,LINES+5,COLS+7,5,5,21,19);
sleep(1);
delwin(pad_ptr);
endwin();
exit(EXIT_SUCCESS);
}
[root@GZH gzh]# sh pad.c
pad.c: line 5: syntax error near unexpected token `('
pad.c: line 5: `int main()'
[root@GZH gzh]#
-----------------------------------------------------------------------------
所有的类似这样的c程序,都出现如下结果:
args.c: line 4: syntax error near unexpected token `('
args.c: line 4: `int main(int argc,char *argv[])'
为什么?