Basic program to create a random number over 10000 and then print out the number in a word format.
The problem is that for the eNum=atoi(Result[i]); line I get a compiler error saying about the variable std::string
Error:argument of type "char" is incompatible with parameter of type "const char*"
What does that mean? I thought I was taking a single char and converting it into an int.
#include <iostream>
#include <stdlib.h>
#include <sstream>
#include <string>
using namespace std;
enum Numbers {Zero, One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Point } eNum;
void main(void)
{
int iRnd, iTemp;
string Result;
iRnd = rand() % (sizeof(int)-10000) + 10000;
ostringstream convert;
convert << iRnd;
Result = convert.str();
cout << "\nRandmon number is: " << iRnd << endl << "Converted Number is : " << Result << endl;
for (int i=0;i<Result.length();i++)
{
eNum = atoi(Result[i]);
cout << eNum;
system("pause");
}
}
The
atoi()function expects a C string. Either get rid of your entire code and usefor conversion, or in your code, change
to