I have program proba2.exe and file text.txt in same folder, when I set command line argument in project properties it can’t open file, but when I run program from command prompt it works fine.
/* count.c -- using standard I/O */
#include <stdio.h>
#include <stdlib.h> // ANSI C exit() prototype
int main(int argc, char *argv[])
{
int ch; // place to store each character as read
FILE *fp; // "file pointer"
long count = 0;
if (argc != 2)
{
printf("Usage: %s filename\n", argv[0]);
exit(1);
}
if ((fp = fopen(argv[1], "r")) == NULL)
{
printf("Can't open %s\n", argv[1]);
exit(1);
}
while ((ch = getc(fp)) != EOF)
{
putc(ch,stdout); // same as putchar(ch);
count++;
}
fclose(fp);
printf("File %s has %ld characters\n", argv[1], count);
return 0;
}



It works fine running from cmd.exe

Also work fine( but writes full path for a name of file) when I specify full path in command arguments project properties window

Make sure that the working directory of the running program is the same in which the program file is stored when you start it from the explorer. I am not sure where this can be set up in Windows, but I think this is the problem..