Does char fName[1024] = ""; set all the elements to 0?
EDIT: I just tried
Code:
for(unsigned int i = 0; i < sizeof(fName); ++i)
printf("%i\n", fName[i]);
And it does.
Ok i know use this:
Code:
int main(int argc, char* argv[])
{
char fName[1024] = "";
int width = 0;
int height = 0;
for(int i = 0; i < argc; ++i)
{
if(argv[i][0] == '-')
{
switch(argv[i][1])
{
case 'w':
case 'W':
if(++i < argc)
width = atoi(argv[i]);
break;
case 'h':
case 'H':
if(++i < argc)
height = atoi(argv[i]);
break;
}
//If it is not a command option (an option starting with '-'),
//its probably the name of the file that was dragged onto the exe
} else if(i == 1)
strncpy(fName, argv[i], sizeof(fName));
}
printf("File: %s\n", fName);
printf("Width: %i\n", width);
printf("Height: %i\n", height);
if(strlen(fName))
{
//Do something
}
return 1;
}