the following code is to read file from stdin but it cant find the file and I cant find the error. Can someone help.
FILE *file;
char filename[200];// "ROMAN_in.txt";
char buffer[1000];
if (fgets(filename, sizeof(filename), stdin) == NULL) // from
stdin(keyboard) to store it in filename
{
printf("Error");
return 1;
}
file = fopen(filename, "r");
if (file == NULL)
{
fprintf(stderr, "File %s not found\n", filename);
return 1;
}
else
{
while (fgets(buffer, strlen(buffer), file) != NULL)
{
printf("%s", buffer);
}
}