I wrote a program to enter several lines from a file. the problem is that I don’t know the length of the lines, so I can’t use fgets because I need to specify the size of the buffer and not use fscanf because it stops at the space pointer I saw a solution in which he recommended using malloc and realloc for of every character taken as input, but I think there’s an easier way, and then I found someone suggesting using
fscanf(file,"%[^\n]",line);
Does anyone have a better solution or can someone explain how this works? (I did not test it)
I use the GCC compiler if necessary
user2039831
source
share