关于system调用错误!!!
#include <stdio.h>
void amendHeadOfConfig(int number)
{
char commandStr[20];
sprintf(commandStr,"sed \'1 c %d\' 1.txt > temp.txt",number);
printf("commandStr: %s\n",commandStr);
system(commandStr);
system("rm -f 1.txt");
system("mv temp.txt 1.txt");
}
int main()
{
amendHeadOfConfig(5);
}
调用后出现segmetion fault .
刚进入linux行业。请赐教!
估计是fork(),然后执行execl,,没有结束掉子进程...
但是想请假这个问题该怎么解决!!!....
期待中 ....