What’s the error in this code? I am just new in C language.
#define FNAME "c:\\users\\mahmud\\desktop\\CDs\\"
#define READ_BIN "rb"
static void open_existing_list()
{
char name[11];
FILE *fptr;
printf("\nPlease enter list name: ");
fflush(stdin);
scanf("%s", name);
fptr = fopen(FNAME name ".dat", READ_BIN);
}
This code is used to read the file name from the user, then open this File.
D:\Mhmud\Mahmud\Programming\C\Videos\VTC - C Programming\Course_Project\main.c In function `open_existing_list':
75 D:\Mhmud\Mahmud\Programming\C\Videos\VTC - C Programming\Course_Project\main.c syntax error before "name"
D:\Mhmud\Mahmud\Programming\C\Videos\VTC - C Programming\Course_Project\Makefile.win [Build Error] [main.o] Error 1
(Edit: it seems it was just a copy-paste typo.)
Add the missing quote and also fix this:
This only works for string literals, since the concatenation occurs at compile time. You want to write something like this: