Advertisement
kivaari

execvp() Example

Oct 11th, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <wait.h>
  4. #include <unistd.h>
  5. #include <string.h>
  6. #include <time.h>
  7. #include <signal.h>
  8. #include <sys/wait.h>
  9.  
  10. int main(){
  11.     char command [20];
  12.     char * parameters[20];
  13.    
  14.     int i;
  15.     for(i = 0; i < 20; i++){
  16.         parameters[i] = (char*)malloc(sizeof(char) * 100);
  17.     }
  18.    
  19.     strcpy(command, "date");
  20.     strcpy(parameters[0], "date");
  21.     parameters[1] = NULL;
  22.    
  23.     execvp(command, parameters);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement