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[])
{
char *cText;
cText = new char[5];
cText = "test11111";
qDebug() << cText;
delete[] cText;
return a.exec();
}
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();
}
To copy to clipboard, switch view to plain text mode
Question is... why does it let me assign a string of more than 5 characters to this memory location?
Bookmarks