Original Post
🔒 Locked
Implement sscanf on stream...
Advertisement
Quote:
Original post by Malchivus
i'm sorry if this is rude, but .. what?
are you talking about a home made scanf function? or do you want to perform scanf on an arbitrary stream?
if you do want the later, try using fscanf or setting stdin to your stream, scanf calls fscanf on the stream stdin.
Yes, I want to implement a scanf on an arbitrary stream.
May the adapter from the arbitrary stream to CRT stream(stdin,stdout etc) is best way...
hmm, if your trying to implement operations on a stream in the way that scanf does on stdin; you could use your own function and choose between data types (float, int etc) and then read byte by byte the data into the arguments.
if your using streams that behave like FILE* than fscanf WILL do all your work for you, the folowing macro explains how scanf and fscanf are related
#define scanf(...) fscanf( stdin, ... )
i hope its helpful, if you want a completely new stdargs function (...) then your goign to have to dig throught some source to find out how to use them ... i'd suggest "the c programing lanuguage" by kerigan and ritchie, but if you don't have a copy the internet should be able to give up the answer you want.
again, i hope i'm being helpful and not confusing ...
if your using streams that behave like FILE* than fscanf WILL do all your work for you, the folowing macro explains how scanf and fscanf are related
#define scanf(...) fscanf( stdin, ... )
i hope its helpful, if you want a completely new stdargs function (...) then your goign to have to dig throught some source to find out how to use them ... i'd suggest "the c programing lanuguage" by kerigan and ritchie, but if you don't have a copy the internet should be able to give up the answer you want.
again, i hope i'm being helpful and not confusing ...
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement