I am writing a C program where I have a directory path from which I need to read several files, one at a time and process them. the file names arise in a pattern. Say RIS01.met, RIS02.met
Now I want to generate a string that stores the path of the file and use it in fopen to open the file. I have pasted here the code that I have written. The problem is that the path that I am specifying in fpath is not working and giving errors on compiling because of the backslash used in the path.
Can you help me find a solution to this problem? Is there an alternative way of generating these file names?
FILE *fopen(), *fp, *fp1
printf("\nWhich set of files do you want to process?\n\n");
counter = 1;
fname = "ROA0";
fname = "UIS0";
fname = "UCO0";
fname = "ULC0";
fname = "UMA0";
fname = "UOA0";
fpath = "c:\raimi\escambia\";
sprintf(filepath, "%s%s%d.met\n", fpath, fname, counter);
fp = fopen(filepath, "r");