This one comes from file-handling.
Say , i have a file of 95,000 lines. I have to analyse only those lines which start with a semi-colon.
So my logic would be like, "Read first character of the line, if it IS a semi-colon, process it, otherwise jump to the next line."
My question is :
Is there any in-built function or logic, that takes me to the next line in the file(that is vertically below) without having to scan the other characters in the same line. That is, i want something that is the equivalent of \n(carriage return + line feed)
At the moment, what i am doing is, storing the entire line in a buffer, and then seeing the first character of the buffer. The code would be something like
fgets(buffer, 100, file_pointer);
if(*buffer == ';')
{
/* process data */
}
else
{
/* again do an fgets and repeat the process */
/* I have not put the whole thing in a loop while posting this, for the sake of simplicity */
}
This logic , OK, helps to process on the basis of the first character, but then, i am again saving the whole thing in a buffer, which is basically reading the entire line. (Atleast i am making fgets read char-by-char)
Please give me your suggestions