-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfileScan.c
More file actions
40 lines (33 loc) · 862 Bytes
/
fileScan.c
File metadata and controls
40 lines (33 loc) · 862 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
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char** argv) {
if (argc != 2) {
perror("Expected 2 arguments: ");
return EXIT_FAILURE;
}
FILE* file;
file = fopen(argv[1], "r");
if (file == NULL) {
perror("File did not open: ");
return EXIT_FAILURE;
}
char string_buffer[1000];
int count = 0;
while (fscanf(file, "%[^\n]\n", string_buffer) != EOF) {
char* cur_token = strtok(string_buffer, " ");
while (cur_token != NULL) {
int i = 0;
while (cur_token[i] != "\0") {
if(cur_token[i] < 96) {
cur_token[i] -= 32;
}
i++;
}
cur_token = strtok(NULL, " ");
}
}
printf("%d\n", count);
fclose(file);
return 0;
}