Nikpa Nikpa - 1 year ago 62
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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download