Dann said:
Quite right. I was thinking about reading only the odd numbered
lines (IOW: skipping lines) which can't really be done without
some sort of assumptions or extensions.
You can't advance to the next line in a C text file without reading
the line and scanning for a '\n'. So where do databases come into
it? A solution might be (using stdin/stdout):
#include <stdio.h>
int main(void) {
unsigned int lines;
int ch;
lines = 0;
while (EOF != (ch = getchar())) {
if (lines & 1) putchar(ch);
if ('\n' == ch) lines++;
}
return 0;
}
If you really want even numbered lines you can just alter the
initialization of lines. It depends if you consider the first line
the zeroth or the first
--
"Our enemies are innovative and resourceful, and so are we.
They never stop thinking about new ways to harm our country
and our people, and neither do we." -- G. W. Bush.
"The people can always be brought to the bidding of the
leaders. All you have to do is tell them they are being
attacked and denounce the pacifists for lack of patriotism
and exposing the country to danger. It works the same way
in any country." --Hermann Goering.