-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtruc.c
More file actions
32 lines (27 loc) · 702 Bytes
/
truc.c
File metadata and controls
32 lines (27 loc) · 702 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <strings.h>
int main(int argc, char *argv[])
{
int fd;
int i;
char str[1024];
char exec_path[1024];
char *wd_ptr = NULL;
wd_ptr = getcwd(str,1024);
fprintf(stdout,"Working dir is %s\n",str);
fprintf(stdout,"Number of args : %i\n", argc);
for(i= 0; i < argc ; i++)
fprintf(stderr,"arg[%i] : %s\n",i,argv[i]);
sprintf(exec_path,"%s/%s",str,"titi");
fd = open(exec_path,O_RDONLY);
if(fd == -1) perror("open");
fprintf(stdout,"================ Valeur du descripteur : %i\n",fd);
fflush(stdout);
fflush(stderr);
sleep(1);
return 0;
}