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

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -