fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main() {
  7. string fileName = "xxx-yyy.abc";
  8.  
  9. if (fileName.find('-')) {
  10. replace(fileName.begin(), fileName.end(), '-', '_');
  11. }
  12.  
  13. cout << fileName.c_str();
  14. }
Success #stdin #stdout 0.01s 2856KB
stdin
Standard input is empty
stdout
xxx_yyy.abc