CaptainProg
CaptainProg

Reputation: 5690

Extracting variables from text file (C)

I need to input four variables into a C program (Win32) from a text file. Each of the variables are on their own line.

example.txt:

2.651127
-7.802776
5.530998
-17.239931

These four variables will each be a float in my program. What is the syntax in C to pass each line to its own variable? There are only ever four numbers, each on their own line.

I previously asked this question as a C++ question; since have discovered that the solution didn't work as I am working in C.

Upvotes: 0

Views: 348

Answers (1)

drdwilcox
drdwilcox

Reputation: 3951

Try using the fscanf function.

Upvotes: 2

Related Questions