How to control the number of chars read in a string by using scanf()? - C++

How to control the number of chars read in a string by using scanf()?

- You can control the number of chars read in a string by using format specifier.

Example:
char buf[25];
scanf("%20s", buf);

- Doing this limits the length of the characters that will be read by scanf() to 20 characters maximum although the buffer can hold 25 characters.

- The scanf() stores the results away in variables which you provide in the argument list.

- It reads the data from the console or from a FILE stream and parses it.
How to detect an end of a file? - C++
How to detect an end of a file? - You can either use the ifstream object ‘fin’ which returns 0 on an end of file...
What are recursive functions?
What are recursive functions? - A recursive function is a function which calls itself...
Difference between an external iterator and an internal iterator
Difference between an external iterator and an internal iterator - An internal iterator is implemented by the member functions of the class....
Post your comment
Discussion Board
really awsm
questions are really good and related to the real matter .. keep posting
http://technosparksforyou.blogspot.in/ 04-2-2012