W
W
Whomai2018-04-06 19:42:36
C++ / C#
Whomai, 2018-04-06 19:42:36

How do the scanf and fgets functions read?

How exactly do the scanf and fgets functions read? Do they read the end of the line, space, and so on?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
1
15432, 2018-04-06
@15432

scanf reads the input string byte by byte, constantly comparing against the given pattern and trying to parse. Both spaces and the end of the line are all parsed. One of the largest functions in the standard library.
fgets is generally simple - almost normal while(c != 0) {c = fgetc();}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question