在c语言里怎么调用linux命令

在c语言里怎么调用linux命令

如下: #include <stdio.h> #include <stdlib.h> #include #include <sys/types.h> int main(void) { printf("real uid=%d, effective uid=%d\n",getuid(),geteuid()); exit(0); user_id_t uid; uid=geteuid(); setuid(uid); //我想在这里调用linux的setup命令 return 0; }
system function


The system function is used to issue a command. Execution of your program will not continue until the command has completed.


Library:   stdlib.h

Prototype: int system(const char *cmd);

Syntax:    system( "cat /etc/hosts");

Notes:
           In Unix systems, the command is passed to "/bin/sh -c" for
           execution. I do not know what handles the command in DOS systems.