Home > Software engineering >  File output not appearing
File output not appearing

Time:01-31

I have a problem, i am not sure how to print in file.
I tried many ways, nothing worked!
Here is my code ,i try to print in file the 2D array board.

fp = fopen("minesweeper.txt", "w ");

if (fp == NULL) {
    return 1;
    printf("ERROR");
}   
    
for (i = 0; i < yi; i  ) {
    for (j = 0; j < xi; j  )
        fprintf(fp, "%c  ",board);
            
    fprintf(fp, "\n");
}

fclose(fp);

CodePudding user response:

Add

fclose(fp);

after the loop block.

It will close the stream and all buffers are flushed.

  •  Tags:  
  • Related