How to use a shortcut to read in the price amount without the dollar sign in C? -



How to use a shortcut to read in the price amount without the dollar sign in C? -

this question similar question asked before why not getting right char values scanf(c linux vi) when scanning file? .

i learned answers question can utilize scanf scanf(" %c") skip on blank spaces , white lines when reading in character. there shortcut can work money too? user types $4.22 standard in. there scanf lets skip on special characters , interpret money amount float? or have scanf character first , scanf float money amount?

if know there $, can include in format, scanf("$%d.%d", &dollars, &cents). seek it!

$ cat scan.c #include <stdio.h> int main() { int dollars, cents; scanf("$%d.%d", &dollars, &cents); printf("that's %d dollars , %d cents.\n", dollars, cents); homecoming 0; } $ create scan cc scan.c -o scan $ ./scan $4.22 that's 4 dollars , 22 cents. $

c

Comments

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -