[C] Search the specific keyword at file
int HAPPY(char *name)
{
char tmp[80];
FILE *fd;
sprintf(tmp,"ps > /happy 2>/dev/null");
system(tmp);
fd=fopen("/happy","r");
if (!fd) return(0);
while (fgets(tmp,sizeof(tmp),fd)!=0)
{
if (strstr (tmp,name))
{
fclose(fd);
return atoi(tmp);
}
}
fclose(fd);
remove("/happy");
return -1;
}
2014年5月23日 星期五
訂閱:
張貼留言 (Atom)
0 意見:
張貼留言