fork download
  1. #include <string>
  2. #include <iostream>
  3. int main () {
  4.  
  5. std::string value = "12,fooBar";
  6.  
  7. size_t pos1=value.find(',');
  8. std::cout << value.substr(0, pos1) << " and "
  9. << (value.substr(0, pos1)).c_str() << std::endl;
  10. }
Success #stdin #stdout 0.02s 2856KB
stdin
Standard input is empty
stdout
12 and 12