fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. int main()
  5. {
  6. const std::string args[1] = { "james.parsons@cplusplus.com" } ;
  7.  
  8. auto pos = args[0].find( '@' ) ;
  9. if( pos != std::string::npos )
  10. {
  11. const std::string user = args[0].substr( 0, pos ) ;
  12. const std::string host = args[0].substr( pos+1 ) ;
  13. std::cout << "user: " << user << " host: " << host << '\n' ;
  14. }
  15. }
  16.  
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
user: james.parsons  host: cplusplus.com