命令行* Linux [英] command line * linux

查看:74
本文介绍了命令行* Linux的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试用C语言编写代码,该代码实现了一个简单的计算器.

i'm trying to write code in C,which implements a simple calculator.

输入应来自命令行,例如,如果我运行

the input should come from the command line, so for example i if i run

./calculator 5 * 2

结果应为10

问题是当我写*时,它将显示当前目录中的所有文件,并且程序运行不正常.

the problem is that when i write * it shows all the files in the current directory and the program doesnt behave well.

总有办法解决这个问题吗?

there is anyway to overcome this problem?

我试图在这里或其他站点中找到解决方案,但没有成功.

i tried to find here or in other sites solutions,without success.

我需要*将被解释为char而不是linux命令.

i need that * will Be interpreted as a char and not as a linux command.

谢谢.

推荐答案

在linux shell中, * 具有特殊含义.除非下面的引用是

In linux shell, the * has special meaning. It is meant for globbing unless it is quoted like below

./calculator 5 '*' 2

您也可以将星号转义,以去除其中的特殊含义

You may also escape the asterisk to strip the special meaning from it

./calculator 5 \* 2

这篇关于命令行* Linux的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆