fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. string line;
  6. cout << "Enter a backslash" << endl;
  7. getline(cin, line);
  8. bool hasBackslash = (line.find('\\',0) != string::npos);
  9. cout << (hasBackslash ? "You have entered a backslash" : "No backslash found");
  10. return 0;
  11. }
Success #stdin #stdout 0s 3276KB
stdin
my text has a backslash \
stdout
Enter a backslash
You have entered a backslash