这段代码有问题吗?
来源:百度知道 编辑:UC知道 时间:2024/06/30 05:32:18
#include <stdio.h>
void main(void);
void main()
{
int test_var = 10;
printf("Test variable before the if statement: %d\n", test_var);
if (test_var>5)
{
int test_var = 5;
printf("Test variable within the if statement: %d\n", test_var);
{
int test_var = 0;
printf ("Test variable within the independent local block: %d\n",test_var);
}
printf ("Test variable after the if statement:%d\n", test_var);
}
void main(void);
void main()
{
int test_var = 10;
printf("Test variable before the if statement: %d\n", test_var);
if (test_var>5)
{
int test_var = 5;
printf("Test variable within the if statement: %d\n", test_var);
{
int test_var = 0;
printf ("Test variable within the independent local block: %d\n",test_var);
}
printf ("Test variable after the if statement:%d\n", test_var);
}
void main(void);
main函数不需要声明就可以直接用
另外,你的主函数少(复制)了一个花括弧}
少了一个 }
很有问题,你的那些大括号是用来干嘛的?
第一个void main(void); 没有用;
大括号用一对就可以了!