Cboehm
Cboehm

Reputation: 43

single quotes (apostrophe) arround letter to print to screen C++

I am doing an assignment and I was wondering how we get single quotes around a letter writing to the screen. I would like to write: The lower case equivalent of 'A' is 'a'. not double quotes like " but single '. Please C++ only, no C.

cout << " The lowercase equivalent of " << mychar << " is " << input << endl;

Upvotes: 0

Views: 7041

Answers (2)

ul90
ul90

Reputation: 787

cout << " The lowercase equivalent of \'" << mychar << "\' is \'" << input << "\'" << endl;

Should work. Single quotes need to be escaped by the backslash.

Upvotes: 0

comingstorm
comingstorm

Reputation: 26097

Single quotes should work just fine inside double quotes:

cout << " The lowercase equivalent of '" << mychar << "' is '" << input << "'" << endl;

Upvotes: 3

Related Questions