Nikpa Nikpa - 8 months ago 40
C Question

Read File: fscanf doesn't read whitespaces?

I have a problem fetching lines from File Pointer using fscanf.

Let's say a want to fetch a line like this:

<123324><sport><DESCfddR><spor ds>

Fscanf fetch only this part:


Does anybody know how to overcome this problem?

Thanks in advance.

Answer Source

In conclusion,the best way to read lines which contain whitespaces is to use fgets:

fgets (currentLine, MAX_LENGTH , filePointer);

Using fscanf you are going to mess with a lot of problems.