You are here:

C/related to files

Advertisement


Question
hi . i have to read from a text file skipping the first three lines of that file. i am able to open and display the whole file but i am not able to understand how skip first three lines and  to access specific content in that file .The txt file is in the form

sno name r1 r2 r3 r4

here sno is long int
name as char
r1 r2 r3 r4 as integers.
i just have to access each line and check the values of r1 r2 r3 r4.

i am stuck please help me out.
thanx in advance.

Answer
Open the file.
Initialize a counter to 0.
Start reading the file (line by line) - on each read increment the counter by 1.
When the counter is less than 3, go back to read.
If it is equal to or greater than 3, display the contents and then go back to read.

C

All Answers


Answers by Expert:


Ask Experts

Volunteer


Narendra

Expertise

I can answer questions in C related to programming, data structures, pointers and file manipulation. I use Solaris for doing C code and if you have questions related to C programming on Solaris, I will be able to help better.

Experience

6.5

Organizations belong to
Sun Microsystems

Awards and Honors
Brain Bench Certified Expert C programmer.
Advanced System Software Certified

©2012 About.com, a part of The New York Times Company. All rights reserved.