Is there a way to use sscanf with stdin?
Posted
by
j_eng
on Stack Overflow
See other posts from Stack Overflow
or by j_eng
Published on 2012-10-08T03:24:23Z
Indexed on
2012/10/08
3:36 UTC
Read the original article
Hit count: 124
I have a program that either takes data from a file or from the standard input. I wrote code for scanning the file using sscanf. I was wondering if I could reuse that code but with stdin instead of using scanf?
Ex:
How could I modify this so that it works with standard input? while(fgets(buffer, MAX_LEN, input) != NULL) { if (sscanf(buffer, "%s %s %s", one, two, three) == 3) { } }
© Stack Overflow or respective owner