Well, the program prompts the user to enter a phrase. And I just want to convert all the letters into numbers starting from 1. So that 'A' would equal 1. 'B' would equal 2, and so on.
And in the end, I want it to output the same phrase as numbers onto the screen.
Code:
#include <iostream>
#include <string>
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++;
}
cout << phrase;
return 0;
}