I am working on a String compare program and i got the program to work properly i was just wondering how to put user input into quotes.
here is my programming
int main
{
const int LENGTH = 40;
char s1[LENGTH], s2[LENGTH];
cout << "== String Compare ==" << endl;
cout << "Enter a word" << endl;
cin.getline(s1, LENGTH)
cout << "Enter another word" << endl;
cin.getline(s2, LENGHT)
if(strcmp(s1, s2) < 0)
{
cout << s1 << " comes before " << endl;
}
else if (strcmp(s1, s2) > 0)
{
cout << s1 << " comes after " << endl;
}
else
{
cout << "Words are exactly the same" << endl;
}
the input is :
Dorito
dorito
the output needs to look like this:
"Dorito" comes before "dorito".
Last edited on