converting letters into numbers.
I'm trying to convert the letters into numbers. But I keep coming into errors in the if loop of the statement. Particularly, in the....
phrase.replace(i,1, 'num');
Right now, I'm getting a warning and 2 errors.
When I take out the single quotes, I just get the 2 errors...
Hellp!!!
Code:
#include <iostream>
using namespace std;
int main ()
{
string phrase;
int i = 0;
int num = 1;
char letter = 'A';
cout << "Enter phrase: ";
getline(cin, phrase);
for (i = 0; i < phrase.size(); i++)
{
if (phrase[i] == letter)
{
phrase.replace(i,1, 'num');
}
letter++;
num++;
}
}