10000 を超える乱数を作成し、その数を単語形式で出力する基本的なプログラム。
問題は、そのeNum=atoi(Result[i]);
行で、変数についてのコンパイラ エラーが発生することです。std::string
Error:argument of type "char" is incompatible with parameter of type "const char*"
どういう意味ですか?私はシングルを取ってchar
それを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");
}
}