Mail Archives: djgpp/1997/11/03/15:00:49
jb AT netcom DOT ca wrote:
>
> could anyone please give me an example of how to use the sscanf
> function?
This is basic C you're asking about here, which is not the purpose of
this newsgroup (try comp.lang.c instead). Any C textbook should tell
you how to use sscanf(), and so should the libc documentation that comes
with DJGPP. Nevertheless, since you took the time to ask I'll go ahead
and answer...
sscanf() parses input from a string in the exact same manner that
scanf() parses input from stdin. You read in a string somehow (via
gets() or whatever), and then tell sscanf() to read from the string.
Otherwise, it's identical to scanf().
Example:
char string[200];
int i1, i2, i3;
printf( "Please type three numbers: " );
gets( string );
sscanf( string, "%d %d %d", &i1, &i2, &i3 );
If this still doesn't clear things up, please post your code that
doesn't work and we'll debug it for you.
--
---------------------------------------------------------------------
| John M. Aldrich | "Courage is the complement of fear. |
| aka Fighteer I | A man who is fearless cannot be |
| mailto:fighteer AT cs DOT com | courageous. (He is also a fool.)" |
| http://www.cs.com/fighteer | - Lazarus Long |
---------------------------------------------------------------------
- Raw text -