This program is supposed to show the position of an alphabet input by the user and then ask the user to input a sentence and make everything in that sentence uppercase. I assumed it to be very easy but I face this problem where my second cin don't show and it just bounds onto the first cin. Please help, thanks. Input with just one characterInput with multiple characters
#include <iostream>
#include <cctype>
using namespace std;
void position_alphabet();
void convert_case();
int main()
{
char characters[50];
position_alphabet();
convert_case();
return 0;
}
void position_alphabet()
{
char alphabet;
char lowered_alphabet;
cout << "Enter an alphabet: ";
cin >> alphabet;
if (isalpha(alphabet))
{
if (isupper(alphabet))
{
lowered_alphabet = tolower(alphabet);
cout << "Position of the alphabet: " << lowered_alphabet - 96 << endl;
}
else
{
cout << "Position of the alphabet: " << int(alphabet) - 96 << endl;
}
}
else
{
cout << "Error! Please enter an alphabet" << endl;
}
return;
}
void convert_case()
{
char characters[50];
cout << "Enter a sentence: ";
cin.get(characters, 50);
cout << "Everything to upper: ";
int len = strlen(characters);
for (int i = 0; i < len; i++)
{
if (islower(characters[i]))
{
characters[i] = toupper(characters[i]);
}
cout << characters[i];
}
return;
}