How to control the number of chars read in a string by using scanf()?
Page 1 of 1
How to control the number of chars read in a string by using scanf()?
By using the a format specifier
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.
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum