Here's my issue I'm running into.
I'm reading in lines of text from a file, but only trying to read in lines that aren't consecutive repeats.
Here's my regular code for reading in the lines of text.
while (((ch = getc (fp)) != EOF))
{
a[j++] = ch;
}
a[j] = '\0';
which works just fine.
When trying to figure out how to go about the problem, I tried having a char array that would read in a line at a time, and then compare it to the previous line using strcomp. If it was a match, it would not add that line into the final char array. It looks something like this:
while (((ch = getc (fp)) != EOF))
{
if (ch != '\n')
{
copynumber++;
temp[j] = ch;
}
else
{
uni = strcmp(identical, final);
if (uni == 0) {
copynumber = 0;
}
else
{
strncpy(identical, temp, copynumber);
final[j] = ch;
}
j++;
}
}
final[j] = '\0';
but I know this won't work for a few reasons. One, I never add the previous chars into the final array. I'm really just lost. Any help is appreciated. Thank you.