The man page of 'sscanf' says:

"EOF is also returned if a read error occurs, in which case the error indicator for the stream (see ferror(3)) is set, and errno is set indicate the error"

I am confused that what kind of read error may occur if sscanf is reading from a buffer on stack???

Recommended Answers

All 3 Replies

Who says the 'buffer on the stack' is formatted properly for sscanf() ?

ok, Let me elaborate, i have a text file that contains lines like:

ABCD 6 0
EFGH 1 0

and so on.....

what i do is, i read each line using 'fgets()' in a char buffer say read_buff, apply a regular expression over it, that ensures the presence of two integers after the name, now by using sscanf i am reading the integers into integer variables, my question is that should i handle the read error specified in man pages, if yes, then please tell me the scenario in which it may occur....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.