栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

C++离线存储登录系统

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

C++离线存储登录系统

直接上代码,

#include
#include
#include 
#include 
#include
using namespace std;
void denglu() {
	while(1) {
		system("cls");
		int sr;
		cout << "登录"<> zh;
		cout << "密码:";
		cin >> mm;
		ifstream ifs;
		ifs.open("yhzl.txt", ios::in);
		while (ifs >> u1 && ifs >> u2) {
			if (u1 == zh && u2 == mm) {
				cout << u1 << " 你好" << endl;
				cout<> x;
					if(x==u2) {
						ofstream oof;
						oof.open("temp.txt", ios::binary | ios::out);     //temp.txt用于交换
						cout << "新密码:";
						cin >> y;
						oof << u1 << "t" << y << endl;
						oof.close();
						ofstream ofs;
						ifstream iof;
						ofs.open("yhzl.txt", ios::binary | ios::out);
						iof.open("temp.txt", ios::binary | ios::out | ios::in);
						while (iof >> u1 >> y ) {
							ofs << u1 << "t" << y << endl;
						}
						cout << "修改成功,请重新登录"<> u1 && ifs >> u2 ) {
							if (u1 == zh ) {
								continue;
							}
							oof << u1 << "t" << u2 <> u1 >> u2 ) {
							ofs << u1 << "t" << u2 << endl;
						}
						ofs.close();
						iof.close();
					}
					if(sr=='2') {
						continue;
					}
				}
				if(sr=='3') {
					system("cls");
					cout<<"已退出登录"<> zh;
		ifstream ifs;
		ifs.open("zh.txt", ios::in);
		while (ifs >> zhe ) {
			if (zh == zhe) {
				cout << "已有账号,是否登录?" << endl;
				cout<>mm;
		ofstream ofs;
		ofs.open("yhzl.txt", ios::out|ios::app);                       //若是电脑读取不了中文的,只能用首字母或数字代替。
		ofs << zh << "t" << mm << endl;        //这里的“t”表示空格,电脑会自动为我们把数据对齐
		ofs.close();
		ofs.open("zh.txt", ios::out|ios::app);                       //应该是我技术问题,若是会单项查找,可以自己尝试
		ofs << zh << endl;
		ofs.close();
		cout << "注册成功" < 

这系统的是用txt文件存储的,

先了解一下文件流,

像

ofs.open("yhzl.txt", ios::binary | ios::out);

 ofs.open是打开,并以某种方式打开,

某种方式取决与ios::后面的代码,向上面的binary,out,还有in, app,ate等

ios是关联 ifstream的,

可以这样引用ifstream

#include

#include 

 就是ofs的头文件,而 是常见输出输入的头文件,如cout,cin

ios::后面的代码意思就像下面这表格

代码用途
in读取txt
out写入txt
app输入标全部跳到最后面
ate打开输入标跳到最后面
binary用二进制打开
trunc把之前写的扔掉

 

ofs.open("yhzl.txt", ios::binary | ios::out);

 这个就是,啊

先不说,

你猜

答案在这     答案

你猜

你猜

你猜

你猜

你猜

你猜

你猜

你猜

你猜

你猜

你猜

你猜

你猜

你猜

你猜

你猜

答案

以二进制写的方式打开yhzl.txt

我爱bug,快说说bug吧

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1027179.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号