Answer to Question #99430 in C++ for Caleb

Question #99430
Write an expression to detect that the first character of userInput matches firstLetter.
#include <iostream>
#include <string>
using namespace std;

int main() {
string userInput;
char firstLetter;

getline(cin, userInput);
cin >> firstLetter;

if (/* Your solution goes here */) {
cout << "Found match: " << firstLetter << endl;
}
else {
cout << "No match: " << firstLetter << endl;
}

return 0;
}
1
Expert's answer
2019-12-03T08:27:45-0500

firstLetter == userInput[0]


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS