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;
}

留言

這個網誌中的熱門文章

逃得了一時 逃不了一世

Google Hangouts

我老闆是真男人!