aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjvech <jmvalenciae@unal.edu.co>2022-01-26 11:38:31 -0500
committerjvech <jmvalenciae@unal.edu.co>2022-01-26 11:38:31 -0500
commit37b598e09250d0b98407b65fe06536aaed98bc4c (patch)
treeedb028a7c13e21b14f2b4079d6e98c3ee73cd1de
parent35b8f486e444400a659c7a00b73e92e50502c6ed (diff)
Selection video error fixed
-rw-r--r--Makefile3
-rw-r--r--main.c14
2 files changed, 9 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index 358439d..64403e7 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
CC = gcc
CFLAGS=-std=c99 -pedantic-errors -Wall
-BIN=cli-tube
+BIN=clitube
build: main.c
$(CC) $(CFLAGS) main.c -o $(BIN)
@@ -18,4 +18,3 @@ install: build
uninstall:
rm /usr/bin/$(BIN)
-
diff --git a/main.c b/main.c
index e3ba8ea..dfe7048 100644
--- a/main.c
+++ b/main.c
@@ -177,21 +177,23 @@ int main(int argc, char **argv)
}
list *q;
- int i = 0, index_video;
+ int i = 0;
+ char index_video[3];
do {
printf(
" ====================================================================\n"
" | YOUTUBE RESULTS |\n"
- " ====================================================================\n\n");
+ " ====================================================================\n"
+ );
for (q = videos->next, i = 1; q != NULL; q = q->next, i++) {
printf("%3d. %s\n", i, q->name);
}
printf("Select one video: ");
- scanf("%d", &index_video);
- } while (index_video >= i);
-
+ fgets(index_video, 3, stdin);
+ printf("\n\n");
+ } while (atoi(index_video) >= i || atoi(index_video) < 1);
- q = list_get_node(videos, index_video);
+ q = list_get_node(videos, atoi(index_video));
char url_watch[45];
sprintf(url_watch, "https://www.youtube.com/watch?v=%s", q->id);
list_free(videos);
Feel free to download, copy and edit any repo