reading in a filename correcty
I'm currently in a intro to C programming class and in a lab we have to open a file to read in data for a maze. The following code is what i have so far and i am using a extra printf statement to debug and figure out why my file reading in ability is not working. when i type in a file path such as "c:\test data.txt" it only scans the first part of the string "c:\test" into char filename. how do i get it scan the whole string into filename?
Thanks
Bobby
Code:
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
FILE *fp;
char filename[1024];
void get_file ();
int main () {
get_file ();
return 0;
}
void get_file () {
char filename[1024];
printf("Please enter the filepath of the maze...\n");
fgets(filename, 1024, stdin);
printf("%s", filename);
}