I've got following code section:
#include "stdafx.h"
int main()
{
string str;
cout << "Enter file name: ";
getline (cin,str,cin.widen('\n'));
char* file_name=new (nothrow) char[str.length()];
if(file_name==0)
{
cout << "Error: Memory could not be allocated!\n";
}
else
{
strcpy(file_name,str.c_str());
WriteFile(file_name);
ReadFile(file_name);
delete[] file_name;
}
getch();
return 0;
}
When I insert the red line, my program warms following error:
Please help me explain this error! Thanks!