My program is supposed to take in some input such as "Hi there." or "I have an a." (notice the ending dot) and output "yes" if the string contains an "a" or "no" if it doesn't. The problem is that cin skips whitespaces and noskipws doesn't seem to work.
The code I've got:
#include <iostream>
#include <string>
using namespace std;
int main() {
string sequence;
cin >> noskipws >> sequence;
for (auto c : sequence) {
if (c == 'a') {
cout << "yes" << "\n";
return 0;
}
}
cout << "no" << "\n";
}
Input: "where are you." Output: nothing
Input: "what." Output: yes