+ 4

Alternative for gets() in C?

Hi, it is a big problem here in sololearn to use gets() function for collecting string input. It generates a disgusting warning in the output. So, I am searching for an alternative. I know I can use scanf("%s",str); but unlikely gets(), it stops getting input when the user enters a whitespace. So, can you please provide me with an alternative for gets()?

12th Jun 2020, 5:18 AM
Mahdee Mohammad
Mahdee Mohammad - avatar
3 Réponses
+ 3
fgets() and getline() are some alternatives https://blogcwi.wordpress.com/2015/04/27/gets-docx/
12th Jun 2020, 5:25 AM
James Clark I. Vinarao
James Clark I. Vinarao - avatar
0
fgets(), u can also try regex with scanf(), or write ur own function.
12th Jun 2020, 5:31 AM
Flash
- 2
stdio.h
12th Jun 2020, 5:37 AM
Flash