How to put input in quotes

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
You need to use blackslash \, and thus you create escape sequences.
http://en.cppreference.com/w/cpp/language/escape

1
2
3
4
5
6
#include <iostream>

int main()
{
    std::cout << "This \"thing\" is my lunch." << std::endl;
}
This "thing" is my lunch.

ok thanks
Topic archived. No new replies allowed.