-2

I'm doing some error handling for argv[1] user inputs, however I don't know how to format a number that has either only a comma or both comma and decimal to be a number without either.

float op2 = atof(argv[1]);

given the conversion above:

1,00 returns 1 (I want 100)

3,000.9 returns 3 (I want 3000.9)

Any idea? I'm still a beginner. Thank you

e55
  • 1
  • 1
  • In a more general sense, what you are asking for is a way to remove specific characters from a string. – 440 Jun 03 '22 at 11:26
  • 2
    Have a look at [How to remove all the occurrences of a char in c++ string](https://stackoverflow.com/questions/20326356/how-to-remove-all-the-occurrences-of-a-char-in-c-string). – rustyx Jun 03 '22 at 11:34

0 Answers0