Im stuck with this problem..... (probably an FAQ but couldnt find it there though).
I know you can pass file names to an argument of main for instance.
int main( int argc, char argv[]);
where argv[0] is the filename.
Now what i want is that the user of my app can shoose wich file he wants to open. That file is needed to let my whole app run.
So i tried several things which are kinda stupid because i knew they would never work like:
Code:
FILE * fl;
char filename[BUFSIZ];
fgets(filename,BUFSIZ,stdin);
fl=fopen("%s","w",filename);
if(fl==0)
perror("\n");
wich obviously wont work since fopen only takes two arguments+ i have the \n character at the end of the string.
Ive also tried several things with the argv thing. But i cant seem to figure out a way of how to get a string from the user and let the app open that "filename".