how can i take input of a file's name?
You mean from the user? Code: char filename[BUFSIZ]; printf("Enter file name: "); fgets(filename, BUFSIZ, stdin); FILE* fp = fopen(filename, mode);
char filename[BUFSIZ]; printf("Enter file name: "); fgets(filename, BUFSIZ, stdin); FILE* fp = fopen(filename, mode);
You might want to strip the newline if any.