sccash/README.md
2026-03-26 22:23:37 -04:00

220 lines
5 KiB
Markdown

# sccash - Simple C Cash
A lightweight, fast CLI currency converter written in C for USD, JPY, and EUR conversions.
## Features
- **Dual Mode Operation**: Command-line arguments for scripting, interactive prompts for manual use
- **Table Formatted Output**: Clean, readable conversion results
- **Lightweight**: No external dependencies, standard C library only
- **Fast**: Compiles to a small, efficient binary
- **Error Handling**: Clear error messages for invalid inputs
## Exchange Rates (as of March 26, 2026)
- **1 USD** = 159.67 JPY
- **1 USD** = 0.866 EUR
- **1 EUR** = 184.20 JPY
*Note: These rates are hardcoded and may not reflect current market rates.*
## Compilation
```bash
gcc -o sccash sccash.c -Wall -O2
```
Or for a static binary:
```bash
gcc -o sccash sccash.c -Wall -O2 -static
```
## Installation
### Option 1: Local Installation
```bash
# Compile first
gcc -o sccash sccash.c -Wall -O2
# Copy to local bin directory
mkdir -p ~/bin
cp sccash ~/bin/
# Add to PATH if not already
export PATH="$HOME/bin:$PATH"
```
### Option 2: System-wide Installation
```bash
# Compile first
gcc -o sccash sccash.c -Wall -O2
# Install to system path (requires sudo)
sudo cp sccash /usr/local/bin/
# Verify installation
sccash --help
```
## Usage
### CLI Mode
Pass three arguments: `amount`, `from_currency`, and `to_currency`.
```bash
./sccash <amount> <from> <to>
```
**Examples:**
```bash
# Convert 100 USD to JPY
./sccash 100 USD JPY
# Convert 50 EUR to USD
./sccash 50 EUR USD
# Convert 1000 JPY to EUR
./sccash 1000 JPY EUR
```
### Interactive Mode
Run without arguments for interactive prompts:
```bash
./sccash
```
Example session:
```
=== sccash - Simple C Cash ===
Available currencies: USD, JPY, EUR
Enter amount: 100
Convert from (USD/JPY/EUR): USD
Convert to (USD/JPY/EUR): JPY
+--------+---------------+--------+----------------+
| FROM | AMOUNT | TO | CONVERTED |
+--------+---------------+--------+----------------+
| USD | 100.00 | JPY | 15967.00 |
+--------+---------------+--------+----------------+
Show all conversions? (y/n): y
+--------+---------------+--------+----------------+
| FROM | AMOUNT | TO | CONVERTED |
+--------+---------------+--------+----------------+
| USD | 100.00 | JPY | 15967.00 |
| USD | 100.00 | EUR | 86.60 |
+--------+---------------+--------+----------------+
Exchange Rates (as of March 26, 2026):
1 USD = 159.67 JPY
1 USD = 0.866 EUR
1 EUR = 184.20 JPY
```
## Sample Output
```bash
$ ./sccash 250 USD EUR
+--------+---------------+--------+----------------+
| FROM | AMOUNT | TO | CONVERTED |
+--------+---------------+--------+----------------+
| USD | 250.00 | EUR | 216.50 |
+--------+---------------+--------+----------------+
```
## Error Handling
```bash
$ ./sccash 100 GBP USD
Error: Invalid source currency 'GBP'
Available: USD, JPY, EUR
$ ./sccash
=== sccash - Simple C Cash ===
Available currencies: USD, JPY, EUR
Enter amount: invalid
Error: Invalid amount
```
## Architecture
sccash uses USD as the base currency for all conversions:
1. Convert source amount to USD
2. Convert USD amount to target currency
This approach minimizes rounding errors and keeps the code simple and maintainable.
## Currencies Supported
- **USD** - United States Dollar
- **JPY** - Japanese Yen
- **EUR** - Euro
Currency codes are case-insensitive (usd, USD, Usd all work).
## Technical Details
- **Lines of Code**: ~200
- **Dependencies**: Standard C library only (stdio.h, stdlib.h, string.h, ctype.h)
- **Memory Usage**: Minimal - uses only the stack
- **Output Format**: Fixed-width table with 2 decimal precision
## Building for Different Platforms
### Linux
```bash
gcc -o sccash sccash.c -Wall -O2
```
### macOS
```bash
clang -o sccash sccash.c -Wall -O2
```
### Windows (MinGW)
```bash
gcc -o sccash.exe sccash.c -Wall -O2
```
## License
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
## Contributing
This is a simple, focused tool. Contributions should maintain the design goals:
- Keep it lightweight
- No external dependencies
- Simple, readable code
- Clear error messages
## Author
Created with simplicity and performance in mind.
---
**Note**: Currency values fluctuate constantly. The exchange rates in this tool are fixed as of March 26, 2026. For real-time rates, consider using a service with API integration.