Atomic_Sheep
9th August 2013, 10:34
Hi Guys,
Just trying to figure out how to use dynamic memory allocation. I've got the following program:
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
char *cText;
cText = new char[5];
cText = "test11111";
qDebug() << cText;
delete[] cText;
return a.exec();
}
Question is... why does it let me assign a string of more than 5 characters to this memory location?
Just trying to figure out how to use dynamic memory allocation. I've got the following program:
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
char *cText;
cText = new char[5];
cText = "test11111";
qDebug() << cText;
delete[] cText;
return a.exec();
}
Question is... why does it let me assign a string of more than 5 characters to this memory location?