- #1
ineedhelpnow
- 651
- 0
Assign the size of userInput to stringSize. Ex: if userInput = "Hello", output is:
Size of userInput: 5
Sample program:
Write an expression to detect that the first character of userInput matches firstLetter.
Sample program:
kinda lost. any hints on where to start?
Size of userInput: 5
Sample program:
Code:
#include <iostream>
#include <string>
using namespace std;
int main() {
string userInput;
int stringSize = 0;
userInput = "Hello";
<STUDENT CODE>
cout << "Size of userInput: " << stringSize << endl;
return 0;
}
Sample program:
Code:
#include <iostream>
#include <string>
using namespace std;
int main() {
string userInput;
char firstLetter = '-';
userInput = "banana";
firstLetter = 'b';
if (<STUDENT CODE>) {
cout << "Found match: " << firstLetter << endl;
}
else {
cout << "No match: " << firstLetter << endl;
}
return 0;
}
Last edited: