C++添加简单的日记记录

#include<fstream>
#include<iostream>
using namespace std;
//这是一种日记记录 b 种
void LOG(char *tx,FILE *fp)
{
fprintf(fp," "); //实现换行
fwrite(tx , sizeof(char), strlen(tx), fp);
}
void main(){

fstream riji; //这又是一种日记记录a 种
int mima;
char b[]="dasdasdasdsaddasdsadsda";
char a[1024];
FILE *fp = fopen("log.txt", "w"); // a 种
int x;
cout<<"请输入密码:"<<endl;
cin>>mima;
if(mima==1234)
{
cout<<"请开始写日记"<<endl;
while(a!="@")
{
cin>>a;
for(int i=0;i<100;i++)
{
if(a[i]=='@')
x=1;

}
if(x==1) break;
riji.open("d:\riji.txt",fstream::in | fstream::out | fstream::app); //a 种
riji.seekg(0,ios::end); //a
riji<<a<<endl;


LOG(a,fp); //b种

LOG(b,fp);

LOG("resond",fp);
fprintf(fp," ");
fclose(fp);
riji.close();
}
riji.close();
fclose(fp);
}


}

原文地址:https://www.cnblogs.com/Pond-ZZC/p/9150194.html