| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1828 人关注过本帖
标题:exit(0);
取消只看楼主 加入收藏
csj_65
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:63
专家分:163
注 册:2010-3-12
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:1 
exit(0);
程序代码:
#include <stdio.h>
int main(void)
{
    struct person
    {
        char name[20];
        char sex;
        int age;
        float height;
    }person1;

    FILE *fp;
    int i;
    char fname[20];
    printf("please input file name:\n");
    scanf("%s",fname);
    printf("please input three person's name,sex,age and height:\n");

    if ((fp = fopen(fname,"wb")) == NULL)
    {
        printf("cannot open this file!\n");
        return 0;
    }

    for (i=1 ;i<4 ;i++)
    {
        scanf("%s %c%d%f",person1.name,&person1.sex,&person1.age,&person1.height);
        if ((fwrite(&person1, sizeof(person1), 1, fp)) != 1)
        {
            printf("write error!\n");
            return 0;
        }
    }

    fclose(fp);

    printf("the content of the file is:\nNAME\t\tsex\tage\theight\n");

    if ((fp = fopen(fname,"wb")) == NULL)
    {
        printf("cannot open this file!\n");
        return 0;
    }

    for (i=1; i<4; i++)
    {
        if ((fread(&person1, sizeof(person1), 1, fp)) == 1)
        {
            printf("%-16s%-8c%-8d%-10.2f",person1.name,person1.sex,person1.age,person1.height);
        }

    }

    fclose(fp);

    return 0;
}
这个程序从书上弄来的,exit(0);语句编译的时候提示函数未申明而无法编译,而书上也没有申明,这是为什么呢?
搜索更多相关主题的帖子: exit 
2010-03-20 22:25
csj_65
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:63
专家分:163
注 册:2010-3-12
收藏
得分:0 
对不起没说清楚。程序中间的return 0;原本是exit(0);
这个头文件果然可以,请问二楼,这个头文件的作用是什么呢?
2010-03-21 10:17
快速回复:exit(0);
数据加载中...
 
   



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

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