execute shell command in C
1
2
3
4
5
6
7
8
9
10
11
# incluide<stdio.h>
int main()
{
FILE* in=popen("your command","r"); //mode=r/w just like open a file
if(NULL==in) exit(1);
char buffer[1024];
while(fgets(buffer,sizeof(buffer),in)!=NULL)
printf("%s",buffer);
//print command output here
return 0;
}