In the below codes, 1st works correctly, but second shows other output. Why? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 2

In the below codes, 1st works correctly, but second shows other output. Why?

https://code.sololearn.com/cWccE3P6Ls54/?ref=app https://code.sololearn.com/cjnEBN0v4L5g/?ref=app what is the mistake?

31st Mar 2021, 4:13 PM
Jawahirullah
Jawahirullah - avatar
2 ответов
+ 3
For scanf(), a space character is a delimiter, so it will stop reading a string when encountering one, and you won't be able to enter a full date. You can use fgets() instead, i.e. fgets( date, 30, stdin ). https://en.cppreference.com/w/c/io/fgets
31st Mar 2021, 4:21 PM
Shadow
Shadow - avatar
+ 3
Thank u
31st Mar 2021, 4:24 PM
Jawahirullah
Jawahirullah - avatar