Execute shell/bash command using C/C++
#include <cstdlib>
#include <cstdio>
using namespace std;
int main()
{
// declaration of record
char record[1000];
// prints the shell command into record
sprintf(record,"/bin/ls");
// this executes what record contains
system(record);
return 0;
}
留言