开发者

scanf on non-STDIN input

开发者 https://www.devze.com 2023-03-25 17:16 出处:网络
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 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).

0

精彩评论

暂无评论...
验证码 换一张
取 消