I've just started to toy around with c++. I wrote a program which takes a string and creates a text pyramid, using a random set of characters from the input. Now, the thing compiles just fine and seems to run well under command prompt. Except if my input is something which seems to be a key word of somekind, i.e. "norbert test", the program goes nuts....printing funny characters for a while, if i type in "debug " ( space is needed to generate the error) then the program crashes, same with other string which seem like they might be system commands.
Here's the source code, which I cannot trace where I'd be getting this behavior from, any help would be appreciated.
using namespace std;
cout<<"What phrase to pyramid?" <<endl;
const int strsize = phrase.size();
string *pyramid = new string[strsize];
int nOfBlanks = 0;
string *outbuf = new string[strsize];
for(int linect = strsize-1;linect >= 0; linect--)
newmainstr.append(nOfBlanks, ' ');
for(int pos = 0;pos <= linect; pos++)
newmainstr.append(1, ' ');
outbuf[linect] = newmainstr;
for(int i = 0;i <= strsize;i++)
cout << outbuf[i] <<endl;
cout << e << endl;