初学Unix,望能得到解释!今晚结贴!
#include <stdio.h>
main()
{
char command[32];
char * prompt="$";
while (printf("%s",prompt),gets(command)!=NULL)
{
if (fork()==0)
execlp(command,command,(char *)0);
else
wait(0);
}
printf("program is over!");
}
当运行编译结果时出现:$,我输入字符串后却需要ctrl+c结束!
并且编译时报:
MyFork_2.c:15:1: warning: no newline at end of file
/tmp/ccO0df6S.o: In function `main':
/tmp/ccO0df6S.o(.text+0x2b): the `gets' function is dangerous and should not be.
这是张尧学《操作系统》上的例子呀!
这段程序是什么意思呀?