UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

#1 2011-06-03 07:56 AM

Offill
Guest

How to skip some lines in C file reading

something like that. That's the problem of lines, you don't know how long
they are, so you need to search for three '\n' chars one way or the other.
One thing to look out for with fgets() is how it handles lines longer than your
bufffer, if they're too long fgets() will return multiple times for one line.

#2 2011-06-03 12:46 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,839
Website

Re: How to skip some lines in C file reading

Are you responding to some other post?  If so, you should've posted in that thread, rather than start a new one...

But, on glibc systems, you can use getline() to read lines of arbitrary length into a dynamically resized buffer, so you never have the issue of fgets() truncating a line...

Offline

Board footer

Powered by FluxBB