I'm unable to enforce char array bounds for some reason. Take a look at the following code (iostream was giving me a hard time so I used the C headers)
Code:
#include <stdio.h>
#include <string.h>
class OOBException {};
class Test
{
public:
char *strtest;
};
int main()
{
Test *test = new Test();
test->strtest = new char[14];
try
{
gets(test->strtest);
printf("%s", test->strtest);
}
catch (OOBException e)
{
printf("exception raised\n");
}
return 0;
}
It compiles okay, but I'm trying to crash it with an exception when I enter more than 13 characters. It simply executes the try clause with no problems no matter what. If I'm inputting more than 13 characters, why doesn't it crash since it goes beyond array boundaries?