I am trying to write a function which converts a number to a string. But when I return from the function, the reviving string - according to debug mode - still is empty, so the program outputs nothing.
What am I doing wrong?
#include <iostream>
#include <string>
using namespace std;
string convertNumberToString(int num);
int main()
{
string num=convertNumberToString(7);
cout<<num<<endl;
fflush(stdin);
cin.get();
}
string convertNumberToString(int num)
{
string scoreString;
itoa(num,const_cast<char *> (scoreString.c_str()),10);
return scoreString;
}