0

I'm trying to print the contents of the file x1.txt using fgetc but it isn't working.

int main(void)
{
    FILE *x;
    char ch;

    x = fopen("x1.txt", "r");

    if (x == NULL)
    {
        printf("unable to access the file\n");
    }
    else
    {
        while (!feof(x))
        {
            ch = fgetc(x);
            printf("%c", ch);
        }
        fclose(x);
    }
    return 0;
}

I'm still considered a beginner.

Jens
  • 69,818
  • 15
  • 125
  • 179
Hegcorp
  • 1
  • 1

0 Answers0