I am relatively new to Windows programming and this forum. As the title says, I'm getting this error whenever I try to run a particular C program I wrote. The program is compiled as x64 running on a 64-bit machine. Edit: After I press the OK button on the popup, I get an "Access is denied" message. The code, which I don't think has anything to do with the problem follows:
// CrtFil2.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "string.h"
//#include BasInc2.c
//#include FilMst2.c
FILE * Opn(char PthNam[], char OpnMod[]);
void main()
{
FILE * FilMstFilPtr = NULL;
FilMstFilPtr = Opn("\\temp\\test.file", "wb");
printf("filptr=0x%p\n", FilMstFilPtr);
return;
}
//******************************************************************************
// Open a file.
//******************************************************************************
FILE * Opn(char PthNam[], char OpnMod[])
{
FILE * FilPtr = NULL;
errno = fopen_s(&FilPtr, PthNam, OpnMod);
if (errno != 0) {
printf("%s\n", PthNam);
perror("Could not open file");
return NULL;
}
printf("file opened for mode %s\n", OpnMod);
return FilPtr;
}
I got the following output on my build:
1>------ Build started: Project: CrtFil2, Configuration: Debug x64 ------
1> CrtFil2.cpp 1> CrtFil2.vcxproj -> C:\$SmpSysLib\$QsysS\CrtFil2\x64\Debug\CrtFil2.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
This worked until about an hour ago. Then I commented some lines and it quit working. I looked through the first 50 answers supplied on a search, and most of them involved running on XP or a particular 3rd party .exe. If this is a duplicate question, please let me know. A couple suggestions I tried were to shut down Visual Studio and restart it, and also shutting and restarting the PC. One answer pointed to this link: https://superuser.com/questions/358434/how-to-check-if-a-binary-is-32-or-64-bit-on-windows. According to the answer, the .exe is compiled as a x86 application. However at the top of the VS display it says x64 as well as in the Property->Configuration Manager. This is on Visual Studio-2015 Community Edition Update 1.
I got the original program working even though the source code remained the same. But the same error cropped up on a different C program. I tried reinstalling VS but got an error when I tried to do it, so I'm somewhat stuck.
Is there a way to fix this problem?