I got this snippet of code from a larger program I've been writing and I'm stuck. All I'm trying to do is read from a file line by line but I keep picking up the new line character, at least that's what I think it is.
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
FILE *file = fopen(argv[1], "r");
char buff[128];
while(fgets(buff, sizeof(buff), file) != NULL)
{
printf("%s\n",buff);
}
}
Ultimately I want to be able to compare the strings I get from splitting the line.
This is my output from a .txt file:
mangle devoid
devoid systems
systems there
there are
I don't get why the extra new lines inbetween. I'd really appreaciate the help