引用 | 编辑
f81513
2010-12-09 21:31 |
楼主
▼ |
||
![]() 老师派了一个作业 是要使用c++建置一个简易的会员系统 我的程式码 不知道为什么新增会员无法新增到档案里 拿原本就存在二元档里面的帐号密码登入也没有办法 已经困惑了好多天也修改了好久了 但是就是不知道哪里出错了 请高手帮忙看一下 万分感谢 #include <iostream> #include <fstream> using namespace::std; struct memberRecordFormat { char account;//帐号 char password;//密码 char name;//姓名 char cellPhone;//手机 }; void check (char* id ,memberRecordFormat memberfile ,int &counter )//看是不是档案里就有的帐号 { int i ; for ( i = 1 ; i <= counter ; i++ ) { while ( strcmp ( id , memberfile.account ) == 0 )//看这个帐号有没有重复 { cout << "此帐号已有人使用\n"; cout << "请输入帐号: "; cin >> id ; cout << endl; } } } int main() { memberRecordFormat memberfile;//新建的资料(档案里的) fstream inFile( "file.dat", ios::in | ios:: out | ios::binary );//开档 while( !inFile )//看有没有开成功 { cout << "File could not be opened" << endl; system("pause"); exit( 1 ); } int counter = -1; while(!inFile.eof())//读档案里面的资料 { counter++; inFile.read( reinterpret_cast< char * > ( &memberfile ), sizeof( memberRecordFormat ) );//把资料存进档案中 } inFile.close();//关档 int first;//选择第一步 int second;//选择第二步 char id;//帐号 char pass;//密码 char nam;//名字 char cell;//手机 cout << "请输入:\n1.会员登入\n2.加入会员\n"; cin >> first;//输入选择 cout << endl; if( first < 1 || first > 2 )//如果没有选1或2时 { while(first < 1 || first &g .. 访客只能看到部份内容,免费 加入会员 ![]()
|