ChinaUnix.net
相关文章推荐:

optarg c 空

怎么样让getopts命令的内置变量color="red">optarg能得到{1..100}扩展后的所有值.测试了一下它总是只能得到扩展后的第一个值,在这里color="red">optarg的值为1.

by kvkingdom - Shell - 2009-03-29 11:45:37 阅读(3744) 回复(6)

相关讨论

getopt实用的 char *string=color="red">optarg; error: syntax error before "char" 不能这样吗? [ 本帖最后由 darkslack 于 2007-9-20 14:07 编辑 ]

by darkslack - C/C++ - 2007-09-20 14:29:36 阅读(3196) 回复(5)

[code]while((opt = getopt(argc, argv, "o:a:s:")) != EOF) { switch(opt) { case 'o': offset = atoi(color="red">optarg); break; case 'a': align = atoi(color="red">optarg); break; case 's': server = (char *)malloc(strlen(color="red">optarg) + 1); server = color="red">optarg; break; default: usage(argv[0]); break; }[/code] 编译时总是提示color="red">optarg没有定义,是要自己来写吗?但是...

by fwizard - C/C++ - 2008-07-19 00:24:10 阅读(13016) 回复(7)

如下: #include #include #include #include #include int main() {     char *p = NULL;     size_t len = 4 * 1024;     p = mmap(0, len, PROT_WRITE, MAP_PRIVATE | MAP_FIXED | MAP_ANONYMOUS, -1, 0);     if (p != MAP_FAILED) {       ...

by windaoo - C/C++ - 2009-07-18 16:17:03 阅读(4673) 回复(15)

题目要求:统计各个数字,白符以及所有其他字符出现的次数。 #include main() { int c, i, nwhite, nother; int ndigit[10]; nwhite = nother = 0; for (i = 0; i < 10; ++i) ndigit = 0; while ((c = getchar()) != EOF) if (c >= '0' && c <= '9') ++ndigit[c - '0']; else if (c == '' || c == '\n' || c == '\t') ++nwhite; e...

by amro - C/C++ - 2008-01-28 18:29:00 阅读(6455) 回复(6)

我用c在Linux上写了一个简单的串口读写程序,大致如下: char buf[64]; int nread,nwrite,len; struct termios opt; int fd=open("/dev/ttyS1",O_RDWR|O_NOcTTY|O_NDELAY); if(fd == -1) { printf("cOM Open Error!\n"); return; } tcgetattr(fd,&opt); cfsetispeed(&opt,B9600); cfsetospeed(&opt,B9600); opt.c_cflag|=(cLOcAL | cREAD); opt.c_cflag &=~PARENB; opt.c_cflag ...

by kqbird - 内核/嵌入技术 - 2005-05-24 10:59:27 阅读(638) 回复(0)

例如: string aaa; aaa="你好"; if(aaa) //这是怎么(写)帮断,谢谢各位兄弟了 { cout<<"同学们好"<cout<<"老师好"<

by shanhan - C/C++ - 2004-10-23 12:59:31 阅读(38895) 回复(11)

#!/bin/bash ALL=false HELP=false FILE=false cOPIES=0 while getopts :ahfgc: OPTION do case $OPTION in a)ALL=true echo "ALL is $ALL" ;; h)HELP=true echo "HELP IS $HELP" ;; f)FILE=true echo "FILE IS $FILE" ;; c)cOPIES=$color="red">optarg echo "cOPIES IS $cOPIES" \?)echo "`basename $0` -[c value]" >&2 ;; esac done 以上是脚本的内容,文件名为fun.sh 在命令行输入./fun.sh -ah -c 显示 ./fun....

by 莫良23 - Shell - 2009-02-08 12:10:39 阅读(3870) 回复(13)

感觉gdb不大好用 程序可以正常运行,但这两个变量确一直是初始值,比如optind=1,color="red">optarg=0; 必须要事先把他们声明为全局变量才可以吗? 是不是还有会有多类似问题出现 或者是我gdb用的还不熟悉,导致了此类情况出现 请高手赐教

by ieangel - C/C++ - 2006-10-27 17:41:55 阅读(1509) 回复(0)

请问getopts和color="red">optarg是什么关系,下面这段关系中,莫名其妙的出现了optart这个参数,我不知道什么意思,请这里的各位给我讲讲,谢谢!!! #!/bin/bash #getopts ALL=false FILE=false HISTORY=false VERBOSE=false HELP=false while getopts afhvhc OPTION do case $OPTION in a) ALL=true echo "ALL IS $ALL." ;; f) FILE=true echo "FILE IS ...

by redliquid - Shell - 2006-08-02 21:50:13 阅读(2227) 回复(3)

[test]$ more test.sh while getopts ab c;do case $c in a) echo $color="red">optarg;; b) echo $color="red">optarg;; \?) echo "Unknow char $c";; esac done 运行下面的命令:[test]test.sh -a 983 没有任何输出???

by lozity - Shell - 2005-03-01 09:12:03 阅读(1766) 回复(4)