Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Project516/c-calc/llms.txt

Use this file to discover all available pages before exploring further.

Non-interactive mode lets you pass all required values directly on the command line and receive an immediate result. This is useful in shell scripts or when you want to avoid interactive prompts. c-calc reads argc at startup: if exactly four values are present (the program name plus three arguments), it calculates and exits without prompting.

Usage syntax

./c-calc <number> <operator> <number>
The three positional arguments map to the first operand, the operator character, and the second operand, in that order.

Examples

Addition:
./c-calc 1 + 1
Result: 2.0000
Division with a repeating decimal:
./c-calc 10 / 3
Result: 3.3333
Modulo:
./c-calc 7 % 3
Result: 1.0000
Division by zero does not terminate the program with an error exit code. Instead, c-calc prints a message and reports 0.0000 as the result.
./c-calc 5 / 0
Divide by 0 errorResult: 0.0000
The two strings are printed without a newline between them because the error message in divide() uses printf without a trailing \n. Treat any result of 0.0000 from a division carefully and validate your inputs beforehand.

Shell quoting for the * operator

Most shells expand a bare * as a glob pattern before passing it to the program, which means ./c-calc 4 * 5 may match filenames in the current directory instead of performing multiplication.
Always quote the multiplication operator when using it on the command line:
./c-calc 4 '*' 5
Single quotes, double quotes, or a backslash escape (\*) all work. This is a shell requirement, not a limitation of c-calc.

How argument detection works

c-calc uses the standard C main signature:
int main(int argc, char *argv[])
argc equals the number of tokens on the command line including the program name. With three arguments, argc is 4. The check if (argc == 4) triggers the non-interactive path. Any other argument count — including zero extra arguments or more than three — falls through to interactive mode.

Build docs developers (and LLMs) love