C语言函数体内,无条件的大括号的作用
这有两个程序:
程序①:
#include<stdio.h>main(){ int b=4; { b=7; printf("b=%d",b); } printf("b=%d\n",b);}
main(){ int b = 2; { int b = 1; printf("b=%d" ,b); // 输出1 } // int a = 2; // 错误 printf("b=%d", b); // 输出2 return 0;}
[root@bogon temp]# cat t1.c#include <stdlib.h>#include <string.h>#include <stdio.h>int main(){ int b = 2; { b = 1; printf("b=%d " ,b); // } printf("b=%d ", b); // putchar('\n'); int c = 2; { int c = 1; printf("c=%d " ,c); // } printf("c=%d ", c); // putchar('\n');}[root@bogon temp]# ./t1b=1 b=1 c=1 c=2 [root@bogon temp]#
[解决办法]
{
}
直接看成
if(1)
{
}
就行。
[解决办法]