-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommands.c
More file actions
35 lines (30 loc) · 802 Bytes
/
Copy pathcommands.c
File metadata and controls
35 lines (30 loc) · 802 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
#include "commands.h"
#include <stdio.h>
#include <stdlib.h>
#include "file_ops.h"
void handle_hello() {
printf("Hello, World!\n");
}
void handle_add(int a, int b) {
printf("%d + %d = %d\n", a, b, a + b);
}
void handle_exit() {
printf("Exiting...\n");
exit(0);
}
void handle_read_file(const char* filename) {
char* content = read_file(filename);
if (content) {
printf("File content:\n%s\n", content);
free(content);
} else {
printf("Error reading file.\n");
}
}
void handle_search_word(const char* filename, const char* word) {
if (search_word(filename, word)) {
printf("Word '%s' found in file.\n", word);
} else {
printf("Word '%s' not found in file.\n", word);
}
}