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.