fork(1) download
  1.  
  2. // Online C++ Compiler - Build, Compile and Run your C++ programs online in your favorite browser
  3.  
  4. #include<iostream>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. string s = "+More";
  11.  
  12. cout<<"s: " << s << "\n";
  13. cout<<"s.length(): " << s.length() << "\n";
  14. cout<<"s.find('+'): " << s.find('+') << "\n";
  15.  
  16. if(s.find('+')<s.length())
  17. { //to find +
  18. cout<<"+ substring found\n";
  19. } else {
  20. cout<<"+ substring not found\n";
  21. }
  22.  
  23. string t = "More++";
  24.  
  25. cout<<"\nt: " << t << "\n";
  26. cout<<"t.length(): " << t.length() << "\n";
  27. cout<<"t.find('+'): " << t.find('+') << "\n";
  28.  
  29. if(t.find("++")<t.length())
  30. { //to find ++
  31. cout<<"++ substring found\n";
  32. } else {
  33. cout<<"++ substring not found\n";
  34. }
  35. return 0;
  36. }
  37.  
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
s: +More
s.length(): 5
s.find('+'): 0
+ substring found

t: More++
t.length(): 6
t.find('+'): 4
++ substring found