I have a simple C code as below :
#pragma warning(disable : 4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <process.h>
#include <math.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <windows.h>
#include <tchar.h>
int main()
{
int ndsc;
char *line = ' ';
FILE *fd;
int x;
wchar_t path[256];
wcscpy(path, L"C:/");
//wcscat(path, L"common\\descr.txt", wcslen(L"common\\descr.txt"));
//Previous
wcscat(path, L"common/descr.txt");
if ((fd = _wfopen(path, L"r")) == NULL)
{
printf("Can't open %s for reading.\n", path);
return 1;
}
for (ndsc = 0; fgetws((wchar_t*)line, 80, fd) != NULL; ndsc++)
{
x = wcslen((const wchar_t*)line);
printf("Length of %d line is %d\n", ndsc, x);
}
fclose(fd);
return 0;
}
I am trying to read a file called descr.txt from C:\Common directory. But in for loop it throws unhandled exception as below :
Can anybody explain me why I am getting this error and how to resolve. By the way this code is being used in an .arx file of AutoCad. I just extracted the part which is throwing error and tried to run it as a standalone project in VS 2015 Update 3. This code is a part of .C file being called by from .NET. Even when executing in the context of .arx ( From AutoCad Clicking on the desired menu ) got the same exception.
Thanks in Advance.