fopen giving error

Hi all

I am trying to open a .par file with the help of fopen but the file is not getting opened.
parfilename is passed as an argument to this, the value is domcol.par.
The domco..par is resiging in same path as the code.

FILE *parafile;
parafile=fopen(parfilename,"rb");
if (!parafile) {
printf("error");
}

I am geeting error.
kindly let me know as how to proceed with this.

Thanks
Anurag

make sure th parfilename is correct file name first, and make sure the .par file exist the same folder with you .exe file. :)
please post all your code~~
Parfilename is correct, it is in the path where the exe is.

ParameterSet=parse_cmdline (argc, argv);

TXMApplicationParameterSet *parse_cmdline (int argc, char **argv)
{
if (strstr (argv[i], "-p") == argv[i]) {

a = &(argv[i][2]);
if (!(*a)) {

/* query name in next parameter */
if ((i + 1) == argc) {
return 0;
}
if (argv[i + 1][0] == '-') {
return 0;
}
i++;
a = &(argv[i][0]);
};
if (*a) {
/* read parameter file */
readparameters (a);
}

void readparameters(char *parfilename)

/*char *parfilename;*/

{
FILE *parafile;
char string[512];
int comment, name;
param **newparam;
param *nextparam;
int i;
char *p;

#ifdef _VISUALC_ //sth to fix compiler bug in VC++ 6
if (firstpara < (param *)0xff) firstpara=NULL;
#endif

parafile=fopen(parfilename,"rb");
if (!parafile) {
if (strlen(parfilename) < 471) {
sprintf(string,"ERROR : Could not open parameterfile (%s)!",
parfilename);
}
else {
sprintf(string,"ERROR : Could not open parameterfile (name to long)!");
}
perror(string);
exit(2);
}


it is the part of the code where the execution is going.
I am passing -p DomCol.par -a DominantColorServer as patameter.

but getting error as
ERROR : Could not open parameterfile (DomCol.par )!
From the part of the code I can't make sure the problem, but I guess the file name with a unwanted blank(from your print error), maybe you can check it.

and you can add [code][ /code] with you code
Last edited on
There is no space at the end.
ERROR : Could not open parameterfile (DomCol.par)! No such file or directory

This is the error
please post all your code~~
Topic archived. No new replies allowed.