Dear All,
I am using Borlands C++ V3 DOS compiler for writing a C programmes.
I am acquainted with scanf() and the use of scan sets. I have used scan sets to define which
letters, numbers and symbols I want to scan in at the command line. This is very useful
because a blank space can be included in the scan set so I can scan in words and not just one
word. Also I can control the scanning in so that over input (If there is such a term) does not
occur. For example if a had a declaration:
char word[6]
I could scan it in with:
scanf(?%5s?, word);
So if I typed 6 or more characters an error could not occur.
The shorter or easier way is to use gets(). I have used this often as well. It automatically
allows a space between words. One thing I have not achieved with gets() is limiting the
scanning in to a determined number of characters. For example if a had a declaration:
char word[6]
I could scan it in with:
gets(word);
But if I typed 6 or more characters then an error could occur.
I want to use gets() because I do not want to define very long scan sets that would be needed
to allow most letters, numbers and characters as well as spaces to be scanned in. However I
do not know if I can limit the scanning in the same way as scanf() does.
Is this possible ?
Any help appreciated
Stephanos