Pro*_*mer 6 c visual-studio-2010
我有以下时间:
#include "stdafx.h"
#include<stdio.h>
int main()
{
int val1,val2;
printf("Enter the first value");
scanf("%d",val1);
scanf("%d",&val2);
int c;
c=val1 + val2;
printf(" the value is : %d", c);
return 0; // 0 means no error
}
Run Code Online (Sandbox Code Playgroud)
我得到错误未声明的标识符c.另外,语法错误.失踪 ; 在类型之前.
但是,如果我更改以上错误消失.请帮忙
#include "stdafx.h"
#include<stdio.h>
int main()
{
int val1,val2,c;
printf("Enter the first value");
scanf("%d",&val1);
scanf("%d",&val2);
c=val1 + val2;
printf(" the value is : %d", c);
return 0; // 0 means no error
}
Run Code Online (Sandbox Code Playgroud)
我在VS 2010中运行C语言.
在C中,至少在过去,变量声明必须位于块的顶部.在这方面,C++是不同的.
编辑 - 显然C99在这方面与C90不同(在这个问题上C99与C++基本相同).