| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1101 人关注过本帖
标题:打开 文件时出错!请帮忙!谢谢!!
只看楼主 加入收藏
corrupt
Rank: 2
等 级:新手上路
威 望:3
帖 子:535
专家分:0
注 册:2004-9-29
收藏
 问题点数:0 回复次数:2 
打开 文件时出错!请帮忙!谢谢!!

我有一段程序,在这里(两个空行之间)出现了问题!!

#include<iostream.h> #include<fstream.h> #include<string.h> #include<stdlib.h> struct Customer { char Customer_name[10]; char Borrow_filename[10]; float Borrow_date; }; struct Filename { char This_Filename[10]; }; int main() { Filename An_Filename_Arry[20]; Customer An_Custmoer_Arry[20]; Filename temp; int i=0; int n=0;

--------------------- ifstream infile ("E:\\filename.txt",ios::in); if(!infile) { cout<<"Error: file filename.txt can't open!"<<endl; exit(1); } while(infile>>temp) { strcmp(An_Filename_Arry[i],temp); i++; } inlife.close();

------------------------- while (n!=3) { cout<<"which file do you like?"; cin.gets(temp); for(i=0;i<20;i++) { int j; j=strcmp(temp,An_Filename_Arry[i]); if(j==0) goto lab; } cout<<"sorry can't find the file"<<endl; exit(0); lab: cout<<"press enter your name:"; cin>>An_Customer_Arry[n].customer_name; cout<<"press the filename:"; cin>>An_Customer_Arry[n].Borrow_filename; cout<<"press the date:"; cin>>An_Customer_Arry[n].Date; n++; } for(i=0;i<20;i++) cout<<An_customer_Arry[i]<<endl; return 0; }

编译 是出现了这样的提示

Compiling... 电影.cpp E:\程序\电影.cpp(29) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'struct Filename' (or there is no acceptable conversion) E:\程序\电影.cpp(29) : fatal error C1903: unable to recover from previous error(s); stopping compilation Error executing cl.exe.

不知道出了什么原因????

--------------------

尽善尽美

搜索更多相关主题的帖子: 文件 
2004-10-10 17:44
kai
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:52
帖 子:3450
专家分:59
注 册:2004-4-25
收藏
得分:0 

// 只是句义上帮你该了该,可以通过编译,连接了。至于程序对与错,我就不保证了。

#include<iostream.h> #include<fstream.h> #include<string.h> #include<stdlib.h> struct Customer { char Customer_name[10]; char Borrow_filename[10]; float Borrow_date; };

struct Filename { char This_Filename[10]; }; int main() { Filename An_Filename_Array[20]; Customer An_Customer_Array[20]; Filename temp; int i=0; int n=0;

//--------------------- ifstream infile ("E:\\filename.txt",ios::in); if(!infile) { cout<<"Error: file filename.txt can't open!"<<endl; exit(1); } while(infile>>temp.This_Filename) { strcmp(An_Filename_Array[i].This_Filename,temp.This_Filename); i++; } infile.close();

//------------------------- while (n!=3) { cout<<"which file do you like?"; cin.getline(temp.This_Filename, '\n'); for(i=0;i<20;i++) { int j; j=strcmp(temp.This_Filename,An_Filename_Array[i].This_Filename); if(j==0) goto lab; } cout<<"sorry can't find the file"<<endl; exit(0); lab: cout<<"press enter your name:"; cin>>An_Customer_Array[n].Customer_name; cout<<"press the filename:"; cin>>An_Customer_Array[n].Borrow_filename; cout<<"press the date:"; cin>>An_Customer_Array[n].Borrow_date; n++; } for(i=0;i<20;i++) cout<<An_Customer_Array[i].Customer_name<<endl; return 0; }


自由,民主,平等,博爱,进步.
中华民国,我的祖国,中华民国万岁!中华民国加油!
本人自愿加入中国国民党,为人的自由性,独立性和平等性而奋斗!
2004-10-11 02:45
corrupt
Rank: 2
等 级:新手上路
威 望:3
帖 子:535
专家分:0
注 册:2004-9-29
收藏
得分:0 

嗯!!太谢谢 了!!

-------------

尽善尽美


2004-10-11 15:46
快速回复:打开 文件时出错!请帮忙!谢谢!!
数据加载中...
 
   



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

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