Click here to Skip to main content
15,887,322 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hey you guys beginner programmer here.Need help in this.

What I have tried:

I tried simply putting in the character in double quotes.Hoping it'll execute but it gives only one answer.
Posted
Updated 20-Aug-18 6:20am

In C, double quotes delimits a string: "Hello"
To specify a single character, use single quotes: 'H', 'e', 'l', 'l', 'o'
So to check if the user entered a yes:
C++
if (inputChar == 'Y' || inputChar == 'y')
   {
   ...
 
Share this answer
 
Comments
Burhan Meraj 21-Aug-18 5:24am    
Thank you.
OriginalGriff 21-Aug-18 5:33am    
You're welcome!
Simply said a string is a char array, so the use is a bit fuid. Take a look at this string tutorial.

Working with strings is a common task so the time to learn it is well invested.
 
Share this answer
 
Comments
Burhan Meraj 21-Aug-18 5:24am    
Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900