fopen "w" return errno ENOENT
My old (worked in older versions of OS and compiler) program has these global definitions and code:
Code:
// file name hard coded for test purpose only
char printerfile[64] = "C:\\xxx\\testenv\\hrrss\\files\\lpt1.txt";
FILE *Prn;
.
.
void main ...
.
.
// the (const char *) was added for test purpose
// I get the same wrong result even when I have
// if((Prn = fopen(printerfile,"w")) == NULL)
if((Prn = fopen((const char *)printerfile,"w")) == NULL)
{
printf("can't open printer; ERROR: %d %s\n", errno, strerror(errno));
printf("%s\n", printerfile);
exit(1);
}
.
.
.
The program give me:
can't open printer; ERROR: 2 No such file or directory
C:\xxx\testenv\hrrss\files\lpt1.txt
errno 2 is ENOENT - No such file or directory
The directory C:\xxx\testenv\hrrss\files exists
I use Visual Studio 2010 on win7 64 bits and I tell the compiler to compile it as C not C++
What am I doing wrong?
Thanks
ZA