← printf, scanf & Overflow

Formatted Receipt Line

easy

Read an item name (a single word, no spaces) and a price, then print exactly:

Item: widget
Price: $4.50

Notice %63s in the starter code, not bare %s – always bound a scanf string read with a width limit one less than your buffer size, or a longer-than-expected input word will write past the end of item and corrupt memory. This is your first real look at “the compiler will not save you” – scanf("%s", item) compiles fine and is a buffer overflow waiting to happen.

Your solution

"Run" uses the sample stdin ("widget 4.5"). "Submit" checks your code against all 3 test cases.

Test results

Submit your solution to run it against all test cases.

Hints

    Reference solution