scanf on non-STDIN input
Is it possible to run scanf
on input that it is not STDIN? What I mean is if I have a string="hello 1 2 3"
, can I run scanf on it to extract the str开发者_StackOverflow中文版ing and three integers?
Is there another function that can do this?
sscanf
on a string (info here)
fscanf
on a file (info here)
similarly sprintf and fprintf to write to a string/file.
If you have a string, sscanf would be more appropriate. The title of your question implies reading from a different stream, for which there are other similar functions (see fscanf).
精彩评论