I am making a little calculator in C, and i want to pass simple arithmetic formulae to my program. But it really does not like me passing character '*' to my program. Why not? And how can I work around this without changing the asterix to something else? Thanks
The character *
is the shell's trigger for expanding matching filenames.
There are several ways to deal with it:
mycalc 5 \* 3
myprog "5 * 3"
*
gets expanded to match all files in the current directory (this is called "globbing"). You need to quote or escape the *, or use a different symbol.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With