编译器的问题? vb6.0 VS visual studio 2012
程序代码:#include<stdio.h>
void main()
{
int i=3,j=5;
int *p,*q;
p=&i;
q=&j;
float a=5.8,b=7.9;
float *c,*d;
c=&a;
d=&b;
char m='I',n='L';
char *x,*y;
x=&m;
y=&n;
printf("i=%d, j=%d\n",*p,*q);
printf("a=%g, b=%g\n",*c,*d);
printf("m=%c, n=%c\n",*x,*y);
}以上很简单的一段代码,主要是试试用指针,在vb6.0里面可以实现,但是在ms visual studio 2012里面,就不行
编译不通过
1>------ Build started: Project: Have a try, Configuration: Debug Win32 ------
1> Have a try.c
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(9): error C2143: syntax error : missing ';' before 'type'
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(10): error C2143: syntax error : missing ';' before 'type'
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(11): error C2065: 'c' : undeclared identifier
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(11): error C2065: 'a' : undeclared identifier
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(11): warning C4047: '=' : 'int' differs in levels of indirection from 'int *'
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(12): error C2065: 'd' : undeclared identifier
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(12): error C2065: 'b' : undeclared identifier
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(12): warning C4047: '=' : 'int' differs in levels of indirection from 'int *'
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(14): error C2143: syntax error : missing ';' before 'type'
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(15): error C2143: syntax error : missing ';' before 'type'
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(16): error C2065: 'x' : undeclared identifier
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(16): error C2065: 'm' : undeclared identifier
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(16): warning C4047: '=' : 'int' differs in levels of indirection from 'int *'
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(17): error C2065: 'y' : undeclared identifier
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(17): error C2065: 'n' : undeclared identifier
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(17): warning C4047: '=' : 'int' differs in levels of indirection from 'int *'
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(20): error C2065: 'c' : undeclared identifier
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(20): error C2100: illegal indirection
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(20): error C2065: 'd' : undeclared identifier
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(21): error C2065: 'x' : undeclared identifier
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(21): error C2100: illegal indirection
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(21): error C2065: 'y' : undeclared identifier
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
1> Have a try.c
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(9): error C2143: syntax error : missing ';' before 'type'
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(10): error C2143: syntax error : missing ';' before 'type'
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(11): error C2065: 'c' : undeclared identifier
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(11): error C2065: 'a' : undeclared identifier
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(11): warning C4047: '=' : 'int' differs in levels of indirection from 'int *'
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(12): error C2065: 'd' : undeclared identifier
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(12): error C2065: 'b' : undeclared identifier
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(12): warning C4047: '=' : 'int' differs in levels of indirection from 'int *'
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(14): error C2143: syntax error : missing ';' before 'type'
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(15): error C2143: syntax error : missing ';' before 'type'
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(16): error C2065: 'x' : undeclared identifier
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(16): error C2065: 'm' : undeclared identifier
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(16): warning C4047: '=' : 'int' differs in levels of indirection from 'int *'
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(17): error C2065: 'y' : undeclared identifier
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(17): error C2065: 'n' : undeclared identifier
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(17): warning C4047: '=' : 'int' differs in levels of indirection from 'int *'
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(20): error C2065: 'c' : undeclared identifier
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(20): error C2100: illegal indirection
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(20): error C2065: 'd' : undeclared identifier
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(21): error C2065: 'x' : undeclared identifier
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(21): error C2100: illegal indirection
1>c:\users\dell\documents\visual studio 2012\projects\have a try\have a try\have a try.c(21): error C2065: 'y' : undeclared identifier
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
请问大家,这是为什么呀?
如果将程序代码改成
程序代码:#include<stdio.h>
void main()
{
int i=3,j=5;
int *p,*q;
float a=5.8,b=7.9;
float *c,*d;
char m='I',n='L';
char *x,*y;
p=&i;
q=&j;
c=&a;
d=&b;
x=&m;
y=&n;
printf("i=%d, j=%d\n",*p,*q);
printf("a=%g, b=%g\n",*c,*d);
printf("m=%c, n=%c\n",*x,*y);
}就 OK了,这又是为什么呀?
谢谢









