I'm having trouble with an example that I am compiling from my C++ All-In-One For Dummies, Second Edition. What it should do is display 10 lines of code containing CR(somenumbers)NQ; However every time I run I get 10 variable addresses. I tried to search the web for this issue but it's pretty particular. I'm running Linux openSUSE 12.1 and using Code::Blocks (GCC). I'm beginning to think there might be a library issue with the included append function. Either that or I'm completely blind and its really obvious.
#include <iostream>
#include <sstream>
#include <cstdlib>
using namespace std;
string *getSecertCode()
{
string *code = new string;
code->append("CR");
int randomNumber = rand();
ostringstream converter;
converter << randomNumber;
code->append(converter.str());
code->append("NQ");
return code;
}
int main()
{
string *newcode;
int index;
for (index =0; index < 10; index++)
{
newcode = getSecertCode();
cout << newcode << endl;
}
return 0;
}