I am making a small calculator in C, and I want to pass simple arithmetic formulas to my program. But I really don't like it when I pass the '*' character to my program. Why not? And how can I get around this without changing the asterisk to something else? Thanks
A symbol *is a shell trigger for extending matching file names.
*
There are several ways to handle this:
mycalc 5 \* 3
myprog "5 * 3"
* , ( "globbing" ). * .
* globbing , . * ,
./yourprogram '10 * 10'
./yourprogram 10 '*' 10
, argv [1] "10 * 10",
Linux (bash, tcsh, ksh, whatever) '*' , . - "x". .
. , . , , :
# For bash set -o noglob # For csh/tcsh set noglob # Now that noglob is set, you can safely use * calc 3 * 3
* " " bash. , . - , .
.
"calc", deb- apt-get install calc, 3 * 3, 3 * 3
, C
* \*