从新写一段清楚的代码 ipsec_rcv.c543行(freeswan中的文件) [code] if(tdbprev == NULL) { spin_lock(&tdb_lock); } #ifdef CONFIG_IPSEC_IPCOMP if (proto == IPPROTO_COMP) { unsigned int flags = 0; if (tdbp == NULL) { spin_unlock(&tdb_lock); KLIPS_PRINT(debug_rcv, "klips_debug:ipsec_rcv: " "Incoming packet with outer IPCOMP header SA:%s: not yet suppor...
by odin_free - C/C++ - 2003-05-08 18:11:54 阅读(1331) 回复(2)
// setup int status = 0; do { // preconditions status = doSomething(); if (status) break; status = doSomethingElse(); if (status) break; // computation status = doWhatYouWantedToInTheFirstPlace(); } while (false); // cleanup return status;
do..while 是重复叙述的循环,可以分成两种模式。 最单纯的就是只有 while 的循环。用来在指定的条件内,不断地重覆指定的步骤。语法如下 while (expr) { statement } 其中的 expr 为判断的条件,通常都是用逻辑运算符号 (logical operators) 当判断的条件。而 statement 为符合条件的执行部分程序,若程序只有一行,可以省略大括号 {}。 下例很有趣,要电脑的浏览器出现十次 "以后不敢了" 的字符串,前面并加上数字,表示说了...
EmpireHawk# dmesg Copyright (c) 1992-2002 The FreeBSD Project. Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994 The Regents of the University of California. All rights reserved. FreeBSD 4.7-RELEASE #0: Wed Apr 21 11:31:36 GMT 2004 root@EmpireHawk.bta.net.cn:/usr/src/sys/compile/EMPIREHAWK Timecounter "i8254" frequency 1193182 Hz CPU: Pentium 4 (1598.65-MHz 686-...
fpin=fopen("1.txt","w"); fpout=popen("/bin/ls","r"); while(fgets(line,MAXLINE,fpin)!=NULL) { if(fputs(line,fpout)==EOF) printf("error"); } 是正确的 而 fpin=fopen("1.txt","w"); fpout=popen("/bin/ls","r"); do { if(fgets(line,MAXLINE,fpin)==NULL) printf("error"); }while(fputs(line,fpout)!=EOF); 错误那? 下面的那一个是死循环; [ 本帖最后由 mu_mu8309 于 2006-12-1 15:04 编...
一直觉得do {} while (false)在写宏时比较有用,但刚刚看到有人这么用: [CODE] do { if (first_condition) break; if (second_condition) break; if (outer_condition){ if (inner_conditio){ break; } } .... } while (false); [/CODE] 据说这样写可以不用goto,但个人感觉并不比用goto好,而且还多了一层嵌套,大家怎么认为呢?或者作者还有什么别的用意?
[code]#include
main() { int count=1,sum=0; do { sum=sum+count; count++; } while(count<=100) printf("sum=%d\n",sum); } [root@mylinux c]# gcc dowhile.c dowhile.c: In function `main': dowhile.c:9: error: syntax error before "printf"
有一个文件内容如下: PID 28606 197 26483 3036 28488 24802 14657 24743 166 181 202 162 165 232 169 Total: 我想当第一列的数值相加,除去行内容为pid和Total,要用do-while循环!