Skip to content
Snippets Groups Projects
Commit 6e453b12 authored by k2-colambatant's avatar k2-colambatant
Browse files

- Files used for Task 8;

parent 28e14f4e
No related branches found
No related tags found
No related merge requests found
Hello
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
char *v[3];
char *command;
if(argc < 2) {
printf("Please type a file name.\n");
return 1;
}
v[0] = "/bin/cat"; v[1] = argv[1]; v[2] = NULL;
command = malloc(strlen(v[0]) + strlen(v[1]) + 2);
sprintf(command, "%s %s", v[0], v[1]);
/*
* Use only one of the following
* commands in each test.
*/
// system(command);
execve(v[0], v, NULL);
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment