I am working on an application in C, using Visual Studio 2015 for getting the files from a path.
Idea is that I run the application and I write the command: list path
.
The application should go at that path and list me all the files from there. All is fine, but I need to save the files in a text file which should be in the project folder.
My problem is that I can't go back from the path I write in command to project path.
For example, I have project in C:\\Visual Studio\\projects\\application
, and I want to create the text file here, but when I write from my keyboard in console that path, for example: list C:\\MinGWStudio
, the text file will be create there.
The code:
printf("Comanda a fost executata cu succes!\n");
SetCurrentDirectory(argv[0]);
FILE *outFile;
outFile = fopen("list.txt", "w+");
printf("%s\n", lista->cale);
fprintf(outFile, "%s\n", lista->cale);