| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1937 人关注过本帖
标题:编译器的问题? vb6.0 VS visual studio 2012
取消只看楼主 加入收藏
chihuyu
Rank: 2
等 级:论坛游民
帖 子:70
专家分:13
注 册:2011-12-26
结帖率:100%
收藏
已结贴  问题点数:6 回复次数:1 
编译器的问题? 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 ==========


请问大家,这是为什么呀?
如果将程序代码改成
程序代码:
#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了,这又是为什么呀?

谢谢
搜索更多相关主题的帖子: visual 编译器 
2013-09-08 06:38
chihuyu
Rank: 2
等 级:论坛游民
帖 子:70
专家分:13
注 册:2011-12-26
收藏
得分:0 
不是visual studio也可以开发c程序的嘛
2013-09-08 08:13
快速回复:编译器的问题? vb6.0 VS visual studio 2012
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.035437 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved