wrote:
> hi there,
> can anyone tell me how to lines from a file which are odd numbered i.e.
> 1st,3rd,5th...lines.
A line is defined in C as a sequence of characters terminated by a
newline character. While the actual end-of-line sequence varies between
operating systems, the C standard library ensures conversion to the
newline character.
So to read odd numbered lines, you'll have to read from the beginning
of the file and keep track of each line. You can store the odd lines
into your buffer while even lines can simply be read and discarded.
> i tried incrementing file pointer by 2 (fp=fp+2) but it does'nt work
A pointer to type FILE is not a "file pointer" in the sense you seem to
understand. It points to an internal, implementation defined, data
structure which hold a lot of "meta" information about the file to
which it is attached. Merely changing this pointer's value will give
you pointer pointing to an unknown area of memory, which will
eventually cause undefined behaviour.
> Can someone give me the code please.
This group helps those who make a sincere attempt, not those who simply
want to pass the course, by hook or by crook, even if it's only for a
mind-numbing BPO job.
So, try your best attempt, and if you encounter problems, post your
question and your code.