Hi all people
Yesterday i was making a simple little program that reads file names by dragging them over the program icon and releasing the mouse button
i expect to receive the file name on "argv[1]", and open it with a simple fopen();
so the command received by the program should be, i think, C:\program.exe "C:\randomfile.txt"
now the question is, if i do that by the command line it goes without problems.
but if i drag&drop files on the program, it crashes when i try to open another second file with fopen();. i'm a beginner and i don't know why
i tried with a very very simple program as that:
1 2 3 4 5 6 7 8
|
#include <stdio.h>
int main(int argc, char * argv[])
{
FILE * File=fopen("file.txt", "rb");
fclose(File);
return 0;
}
|
i just tryed it, and if i run it without arguments, i get no errors. no errors even if i give program.exe "ramdomfile.txt".
but if i drag files over, it crashes every time, apparently because i open a file with fopen()
does anyone here knows the error?