Hi i have a chicken and egg problem. I want to read a file line by line into a char *, let's say str. In order to malloc str I need to know the length of the line which I cannot have unless I read it... The only way I can see is reading character by character till \n character encountered and realloc str in every character. But it seems to me that this quite inefficient and I was thinking of using fgets instead.
Any clues on that?
Cheers.



LinkBack URL
About LinkBacks



