Scanf() is an inbuilt function in the C Standard libraries. This is used to get input from the user and store that in a variable.
scanf provides inbuilt mechanisms to tackle with de-limiters which many people are not aware of. So, today we'll show you how you can limit your input till a certain symbol.
Consider we have a variable declared as
Reading a String:
To read a string usually we use '%S'. Instead of that we can also use the following way to get the value till you encounter '\n' and discard it.
This only stores the value till '\n' is encountered and discards it.
To read till a Comma:
Just like the above scenario we will use comma (,) as our delimiter. That would be,