C++ c++;,将数据发送到输出文件
我创建了一个小的分配系统。请告诉我如何将数据发送到输出文件/数据库文件。我需要保存记录,然后根据需要进行编辑和删除。因此,我需要将数据发送到某个数据库文件。好心帮忙C++ c++;,将数据发送到输出文件,c++,database,C++,Database,我创建了一个小的分配系统。请告诉我如何将数据发送到输出文件/数据库文件。我需要保存记录,然后根据需要进行编辑和删除。因此,我需要将数据发送到某个数据库文件。好心帮忙 #include <iostream> #include <string> #include <cstring> #include <fstream> #include <iomanip> #include <windows.h> #include <ss
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <windows.h>
#include <sstream>
#include <algorithm>
#include <conio.h>
#include <stdio.h>
#include <cstdlib>
#include <iomanip>
#include <dos.h>
using namespace std;
string userName;
string passWord;
string selection;
int option;
struct patientinfo {
string PatientFname;
string PatientLname;
int Age;
int ContactNo;
string TreatmentType;
string AppDate;
string AppTime;
int eReciptId;
};
int num;
patientinfo emp[50];
ofstream outputFile("ST.txt");
int main()
{
int i=num;
num+=1;
cout<< endl << endl << endl << endl << endl << endl
<< setw(65)<<"|Booking|" << endl << endl << endl << endl
<< setw(30)<<"First Name : ";
cin>>emp[i].PatientFname;
cout<< setw(30)<<"Last Name : ";
cin>>emp[i].PatientLname;
cout<< setw(30)<<"Age : ";
cin>>emp[i].Age;
cout<< setw(30)<<"Contact No : ";
cin>>emp[i].ContactNo;
cout<< setw(30)<<"Appointment Date : " ;
cin>>emp[i].AppDate;
cout<< setw(30)<<"Appointment Time : ";
cin>>emp[i].AppTime;
};
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
使用名称空间std;
字符串用户名;
字符串密码;
字符串选择;
int选项;
结构信息{
字符串名;
字符串名称;
智力年龄;
国际联络号码;
字符串处理类型;
字符串AppDate;
字符串应用时间;
INTERECIPTID;
};
int-num;
patientinfo emp[50];
流输出文件(“ST.txt”);
int main()
{
int i=num;
num+=1;
cout猜你在书写时必须使用特定的格式,这样你才能读回。可能每个患者之间都有逗号。例如
if (outputFile.is_open())
{
for(int x=0; x<50; i++
{
outputFile << emp[i].PatientFname << "," <<emp[i].PatientLname << "," << emp[i].Age <<"\n";
}
outputFile.close();
}
if(outputFile.is_open())
{
对于(int x=0;xSo到目前为止您尝试了什么?尝试在流中发送输出文件。不起作用。num
未初始化,因此i
具有不确定的值。UB。您应该会收到一个错误/警告。@ceranda和您错误地键入了for
-循环使用我上面所说的内容。如果不知道要求/排除项,很难说对于任务是。对于类似的东西,我总是使用sqlite的相当轻量级的选项。它无处不在,稳定、免费,它是一个能够接受SQL语句的数据库引擎。它使以后检索和修改记录变得轻而易举。如果没有正式禁止,我会在心跳中使用它。