Skip to content

Shopping Cart Program

XiaoMāo edited this page Oct 15, 2026 · 1 revision

Shopping-Cart-Program

Type: Bro Code course project Date: Sept 2026 Concepts: char[], float, int, fgets, scanf, strlen, formatted output

What it does

Takes an item name, price, and quantity from the user and prints the total cost, formatted with a currency symbol and two decimal places.

What I learned

fgets keeps the trailing newline in the buffer, so it has to be stripped manually (item[strlen(item)-1] = '\0'), a gotcha that higher-level languages hide. I also practiced mixing string, float, and int input in one program and formatting output cleanly.

Source

[View the code on GitHub](https://github.com/Xiao-XC/C-Practice-Projects/tree/main/Shopping-Cart-Program)

Back to Home

Clone this wiki locally