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
Try : Code: FILE *parafile; parafile=fopen(parfilename,"rb"); if (parafile==NULL) { printf("error"); }
> The domco..par is resiging in same path as the code. OK, but is the file in the current directory, i.e. where you are now? A NULL return from fopen usually means the file can't be found. If it's not in the current directory then you need to include the full path to the file, and if it's in the same directory as the file then you can get the location from argv[0]. Saswat: if (!parafile) and if (parafile==NULL) are equivalent.