I am getting "crt detected that the application wrote to memory after end of heap buffer" when deleting my char source[]
Size and array value are read from file, size_orig is initialized before creating source[] even if file input is wrong
I deleted from code anything that is not connected with initializing and deleting source[]
int main()
{
int size_new = 26;
std::ifstream in;
std::string OrigFile;
std::cout << "FILENAME\n";
std::cin >> OrigFile;
in.open(OrigFile);
if (!in)
{
std::cout << "FILE COULDN'T BE OPENED\n";
exit(-1);
}
int size_orig = 0;
in >> size_orig;
if (!in)
{
std::cout << "SIZE IS NOT A NUMBER";
in.close();
exit(-1);
}
char* source = new char[size_orig];
while (!in.eof())
{
in >> source;
for (int i = 0; i < size_orig; i++)
{
if( !(isalpha(source[i])))
{
std::cout << "ERROR_TEXT";
delete[] source;
in.close();
exit(-1);
}
}
}
delete[] source;
return 0;
}
After researching I initialized size_orig before reading its value from file, didn't help