| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 537 人关注过本帖
标题:菜b向刚刚呢个写入文件的结构体中添加了一个创建功能。。。然后就全是错误了 ...
取消只看楼主 加入收藏
saber930490
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2012-12-20
结帖率:66.67%
收藏
已结贴  问题点数:10 回复次数:2 
菜b向刚刚呢个写入文件的结构体中添加了一个创建功能。。。然后就全是错误了啊啊啊。我把我觉得错的地方标了一下
#include<stdio.h>
struct student
{
    char name[10];
    char sex;
    long int phone;
    char adress[20];
    long int QQ;
};

int main()
{FILE*fp;
    int i;
    struct student stu[20]={{"Lily",'W',111123,"apple road",56443256},
    {"Bob",'M',657894,"banaba road",554511283},
    {"Tom",'M',897523,"tower road",564432123},
    {"Kity",'W',495821,"rain road",56458369},
    {"Tony",'M',367498,"gold road",564454781},
    {"Sed",'M',232599,"air road",294658715}};

    fp=fopen("D:\\stl.txt","wb");
    for(i=0;i<6;i++)
        fprintf(fp,"%s\t %c\t %ld\t %s\t %ld",stu[i].name,stu[i].sex,stu[i].phone,stu[i].adress,stu[i].QQ);
    fclose(fp);
    [color=#FF0000]i=Creat(i);[/color]

return 0;
}

int Creat(int num)
    {
        FILE*fp
        int j=num+1;
        printf("请输入姓名(英文):");
        scanf("%s",stu[j].name);
        printf("请输入性别(m男,w女):");
        scanf("%c",stu[j].sex);
        printf("请输入电话:");
        scanf("%ld",stu[j].phone);
        printf("请输入地址(英文):");
        scanf("%s",stu[j].adress);
        printf("请输入QQ号:");
        scanf("%ld",stu[j].QQ);
        num++;
        fp=fopen("D:\\stu.txt","wb");
        fprintf(fp,"%s\t %c\t %ld\t %s\t %ld",stu[j].name,stu[j].sex,stu[j].phone,stu[j].adress,stu[j].QQ);
    fclose(fp);
    for (j=0;j<num;j++)
printf("%d\t %s\t %c\t %5d\t %s\t %5d\n",stu[i].count,stu[i].name,stu[i].sex,stu[i].phone,stu[i].adress,stu[i].QQ);
    return(num)
    }
搜索更多相关主题的帖子: long include 结构体 
2013-01-02 11:51
saber930490
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2012-12-20
收藏
得分:0 
C:\Users\Administrator\Desktop\Debug\新建文件夹 (9)\课程设计.cpp(39) : error C2065: 'Creat' : undeclared identifier
C:\Users\Administrator\Desktop\Debug\新建文件夹 (9)\课程设计.cpp(47) : error C2373: 'Creat' : redefinition; different type modifiers
C:\Users\Administrator\Desktop\Debug\新建文件夹 (9)\课程设计.cpp(47) : error C2601: 'Creat' : local function definitions are illegal
C:\Users\Administrator\Desktop\Debug\新建文件夹 (9)\课程设计.cpp(71) : fatal error C1004: unexpected end of file found

这个是错误- -
2013-01-02 11:55
saber930490
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2012-12-20
收藏
得分:0 
回复 3楼 wangjialong
这是个失误,主要是调用函数的语句不明白怎么出错儿了?
2013-01-02 13:12
快速回复:菜b向刚刚呢个写入文件的结构体中添加了一个创建功能。。。然后就全是 ...
数据加载中...
 
   



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

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