2
I would like to make an extremely simple program, but there is a problem that I would like to solve. Follow the code:
#include<stdio.h>
main(){
float num;
printf("Insira metros para converter para cm): \n");
fflush(stdin);
scanf("%f", &num);
printf("%.2f\n", num*100);
system("pause");
}
If I don’t add the local library. h, for the user to enter a decimal number he will have to separate with point (.), and if I add it he will have to separate with comma (,). Is there any way my program will accept both comma and dot to separate decimals?
Thank you.
You read the input as string, swap (if any) the commas by dots, then convert the string (with dots) to floating comma value.
– pmg
You can show me something to teach me that?
– Jackgba