0
printf("Batch Mode\n");
FILE* batchFile;
char oneLine[LINE_MAX];
batchFile = fopen(argv[1], "r");
bool done = false;

if(batchFile == NULL)
{
    perror("File");
    exit(1);
}   
while (fgets(oneLine,LIMIT,batchFile) != NULL && !done)
{
    processLine(oneLine, done);
}

So I have some concern regarding my code above. The problem is fgets still gets lines even if the lines just contain a newline character. So I need to eliminate this or at least be able to check for lines that contain only a newline.

I tried

if (strcpy(line, '\n') == 0)
{
    printf("an Enter key line\n");
    return;

}

But still it doesn't work.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Pro
  • 173
  • 4
  • 15
  • The code with `strcpy()` should not have compiled. If it did, you're either ignoring compiler warnings or not using enough of them. If you have the `` included, the code should be rejected by the compiler. – Jonathan Leffler Feb 06 '16 at 02:38
  • And also, nothing in this code changes `done` after it is initialized to `false`. – Jonathan Leffler Feb 06 '16 at 03:05

0 Answers0