summaryrefslogtreecommitdiff
path: root/C/HF/str.c
diff options
context:
space:
mode:
authorCarlos Maiolino <[email protected]>2025-09-06 09:26:21 +0200
committerCarlos Maiolino <[email protected]>2025-09-06 09:26:21 +0200
commit973e27b243ea7f12b6743894465c67a4a6a87eb2 (patch)
tree006a2d9fc8f86b4914499302325fbcaa3941e17c /C/HF/str.c
parent736967952470e740781c95cf5afb7e705ec59030 (diff)
Move some other code here
Signed-off-by: Carlos Maiolino <[email protected]>
Diffstat (limited to 'C/HF/str.c')
-rw-r--r--C/HF/str.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/C/HF/str.c b/C/HF/str.c
new file mode 100644
index 0000000..f3e635a
--- /dev/null
+++ b/C/HF/str.c
@@ -0,0 +1,33 @@
+#include <stdio.h>
+#include <string.h>
+
+char tracks[][80] = {
+ "I left my heart in MIT",
+ "Newark, Newark",
+ "Dancing with a Doll",
+ "From here to eternity",
+ "The girl from Iwo Jima",
+};
+
+void find_track(char s[])
+{
+ int i = 5;
+
+ for (i = 0; i < 5; i++) {
+ if (strstr(tracks[i], s)) {
+ printf("Found track: %i - %s\n", i, tracks[i]);
+ return;
+ }
+ }
+ printf("Track not found: %s\n", s);
+}
+
+int main(void)
+{
+ char i_str[80];
+
+ printf("Type track: ");
+ gets_s(i_str, 80);
+ find_track(i_str);
+ return 0;
+}