Neither do I, since you've shown no code and I have no idea
what getline() function you're talking about (there's no getline()
in the Standard library, so it must be something you got elsewhere).
If you posted a short, complete program that demonstrates the
problem, and at the very least provided a pointer to the source of
this getline() function, maybe someone could help. As it is ...
It's customary at this point to say "You have an error on
line forty-two" or "The bank foreclosed on my crystal ball" or
"Please stop thinking in Hungarian; I'm having trouble reading
your mind," but what all of these mean is
The Doctor Needs More Than "It Hurts" To Make A Diagnosis.
ehehe,
oK I'll give the whole storyline.. I picked up the first google
results (like this one:
http://linux.die.net/man/3/getline) for "man
getline" and they show this "getline" function behaviour which is
always the same -and it works in my code-
Reading the manpage I erroneously thought such function was defined in
the stdlib.. and on the example too, they include stdio and stdlib
only.. the above define "_GNU_SOURCE" stands for something that I
*don't* know so I ignored it (while probably it's the key).
Anyway.. the code is this:
#define _GNU_SOURCE
#include <stdio.h> /*fopen*/
#include <stdlib.h>
long filelines(const char *filename){
FILE * fp;
char * line = NULL; size_t len = 0;
long lines = 0;
fp = fopen(filename, "r");
if (fp == NULL) return lines;
while (( getline(&line, &len, fp)) != -1) {
lines++;
}
if (line) free(line);
//fclose(fp); //[Argh here I crash ... BUT WHY?]
return lines;
}