-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrings.c
More file actions
37 lines (34 loc) · 754 Bytes
/
Copy pathstrings.c
File metadata and controls
37 lines (34 loc) · 754 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
#include <stdio.h>
#include <string.h>
char tracks[][80] = {
"I left my heart in Harvard Med School",
"Newark, Newark - a wonderful town",
"Dancing with a Dork",
"From here to maternity",
"The girl from Iwo Jima",
};
void find_track(char search_for[]) {
for(int i = 0; i < 5; i++) {
if(strstr(tracks[i], search_for)) {
printf("Track %i: '%s'\n", i+1, tracks[i]);
}
}
}
void reverse(char *str) {
size_t length = strlen(str);
char *t = str + (length - 1);
while(t >= str) {
printf("%c", *t);
t = t - 1;
}
puts("");
}
int main(){
char search_for[80];
puts("Search for:");
scanf("%79s", search_for);
search_for[strlen(search_for) - 1] = '\0';
find_track(search_for);
reverse("ABC");
return 0;
}