string input in C | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

string input in C

I am trying to make a Task manger (To do list) program where I can add, remove or view tasks. then mark it as completed.. etc. But dealing with strings is kind of difficult to me. Please help me at this point here: What is the problem with scanf function in case 1? https://code.sololearn.com/cI6z8YPESTjp/?ref=app

15th Aug 2023, 3:46 AM
rah123
6 Answers
+ 5
rah123 , > 2 issues are creating an infinite loop: using this line: goto task_list; the switch case does not handle the number `4` from input, so to exit the program is not possible.
15th Aug 2023, 2:54 PM
Lothar
Lothar - avatar
15th Aug 2023, 6:41 PM
JaScript
JaScript - avatar
+ 1
try this in case 1 :- case 1: printf("Enter task: "); scanf("%s",task_list[i]); printf("%s\n", task_list[i]); printf("Task added!\n\n"); if(i<NUMBER_OF_ELEMENTS) { i++; choice = 4; goto task_list; } printf("There are no task left\n"); goto task_list;
16th Aug 2023, 4:27 PM
Alhaaz
Alhaaz - avatar
+ 1
Printf("enter string"); Scanf("%s",&str); // string input from user in c
16th Aug 2023, 6:02 PM
Mikēy
+ 1
I would go at this project using structs and a linked list. Are you still working on it?
20th Aug 2023, 4:00 AM
William Owens
William Owens - avatar
0
should I make it with if instead?
15th Aug 2023, 4:01 PM
rah123