+ 1

Can scanf() function can overwrite the limit setted by char array data type to store data?

If you find any difficulty to understand my question please see the below code https://code.sololearn.com/cQqH7MnIn2FJ/?ref=app Please answer my question.I am newbie in C....

10th Sep 2020, 6:38 AM
Yogeshwaran P
Yogeshwaran P - avatar
2 odpowiedzi
+ 1
Need to take good care when taking input. In language like C, the coder is responsible for properly allocating and deallocating memory e.g. string buffer. This is not only `scanf` issue, `fgets` also writes past the actual buffer size if we set it to be. I see you have learned how to limit the amount of characters read in by `scanf`, given that knowledge, I suppose you know that we should not allow input reads to go past the size of buffer we specified. That is our responsibility as the code writer : )
10th Sep 2020, 10:17 AM
Ipang
+ 2
Sure Ipang 😃👍 Thanks for your explanation....😊
10th Sep 2020, 10:20 AM
Yogeshwaran P
Yogeshwaran P - avatar