Beginner: I/O using .txt files
Hello, I am writing a program to read characters from a txt file, but initially asking the user via the console to input the file name. this is what i've come up with so far but in unsure how to declare the file name at the pointer as a user in putted value.
Code:
#include<stdio.h>
int main(void)
{
char buffer[256];
char file[14];
printf("Please enter the file name you want to read: ");
scanf("%s \n", &file);
FILE *file_pointer=NULL;
file_pointer=fopen("%s", "r");
while (fgets(buffer,256,file_pointer));
{
printf("%s",buffer);
}
}
Regards
Ryan