c - 通过bash,输入含有()左右括号的字符串
本文介绍了c - 通过bash,输入含有()左右括号的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
#include<stdio.h>
#include<string.h>
int main( int argc, char* argv[] )
{
puts( argv[1] );
return 0;
}
输入样例:()www
bash: 未预期的符号 `www' 附近有语法错误
解决方案
可以将包含特殊字符的参数用单引号引起来,或者通过反斜杠转意:
[root@web ~]# ls ()
-bash: syntax error near unexpected token `('
[root@web ~]# ls '()'
ls: cannot access (): No such file or directory
[root@web ~]# ls \(\)
ls: cannot access (): No such file or directory
这篇关于c - 通过bash,输入含有()左右括号的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文