You are on page 1of 1

#include <stdio.

h>
char InputOneChar(char prompt[])
{
printf("%s", prompt);
char temp[1024];
scanf("%s", temp);
return temp[0];
}
int main(void)
{
printf("\n");
char ch = '\0';
char filename[] = "$.c\0";
ch = InputOneChar("Enter 1, 2 or 3: ");
filename[0] = ch;
FILE* file = fopen(filename, "r");
ch = fgetc(file);
while (ch != EOF)
{
printf("%c", ch);
ch = fgetc(file);
}
fclose(file);
printf("\n\n");
return 0;
}

You might also like