-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcat.c
More file actions
53 lines (50 loc) · 929 Bytes
/
Copy pathcat.c
File metadata and controls
53 lines (50 loc) · 929 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
#include <syscall.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
int main(int argc, char *argv[])
{
if(!strcmp(argv[1],"-E")){
DIR* de=opendir(".");
FILE* opens=fopen(argv[2],"r");
char character;
character=fgetc(opens);
while (character!=EOF){
if(character=='\n'){
printf("$");
}
printf("%c",character);
character=fgetc(opens);
}
}
if(!strcmp(argv[1],"-n")){
DIR* de=opendir(".");
FILE* opens=fopen(argv[2],"r");
char character;
character=fgetc(opens);
int z=1;
printf(" %d ",z);
while (character!=EOF){
printf("%c",character);
if(character=='\n'){
z++;
printf(" %d ",z);
}
character=fgetc(opens);
}
}
else{
DIR* de=opendir(".");
FILE* opens=fopen(argv[1],"r");
char character;
character=fgetc(opens);
while (character!=EOF){
printf("%c",character);
character=fgetc(opens);
}
}
return 0;
}