hi can anyone help me i am trying to get a random character generator which generates 10 characters in ASCII range and then cast them into characters
heres my code but its not working. it says error C2440: '<function-style-cast>' : cannot convert from 'std::string' to 'char'
heres my code
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>
using namespace std;
int main()
{
string RandNum; // name of the string
char UserLetter; // what the user will enter and the place of storage in char
for (int i(0); i !=10; i++) // a for loop which will run until the game has 10 letters
{
srand ((unsigned) time(0) );
RandNum = 65 + rand()% 26; // generate the numbers in the ASCII range
}
cout << (char)RandNum << endl; // casting them into characters
return 0;
}
any help will be greatly appreciated