How do I read data from a text file without using fscanf?
rajsharma_85
0
Newbie Poster
Recommended Answers
Jump to PostGiven an opened file
while (fgets(line_buffer, sizeof line_buffer, file_handle) != NULL) { /* do what you want with the data stored in line_buffer */ }
Jump to PostInput redirection is done at the command-line level, not from within a C program. If you want to redirect a file into the C program then the C program will want to read the data from stdin. You can still use Aia's example, but replacing file_handle with stdin.
There …
All 8 Replies
Aia
1,977
Nearly a Posting Maven
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
rajsharma_85
0
Newbie Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Aia
commented:
Very proper.
+9
Aia
1,977
Nearly a Posting Maven
abhimanipal
91
Master Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Narue
5,707
Bad Cop
Team Colleague
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.