i have created one class of doctor and i want to insert data of doctor in note pad file (Doctor.txt) but data do not have a symmetry because there is no fixed length of my inputs in the line...
我已经创建了一类医生,我想在记事本文件(Doctor.txt)中插入医生的数据,但数据没有对称性,因为我的输入中没有固定的长度...
int DocID;
string Name,Department,Specification,Address,PhNo ;
Doctor D;
ofstream myfile;
myfile.open ("Doctor.txt",ios::app);
cout<<"please enter doctor ID: ";
cin>> DocID;
cout<<"please enter doctor Name: ";
cin>> Name;
cout<<"please enter doctor Department name: ";
cin>> Department;
cout<<"please enter doctor specification: ";
cin>> Specification;
cout<<"please enter doctor Address: ";
cin>> Address;
cout<<"please enter doctor Phone Number: ";
cin>> PhNo;
D.set_data(DocID,Name,Department,Specification,Address,PhNo);
myfile <<endl<<D.get_DocID()<<" "<<D.get_Name()<<" "<<D.get_Department()<<" "<<D.get_Specification()<<" "<<D.get_Address()<<" "<<D.get_PhNo();
myfile.close();
how can i generate a symmetrical .txt file using fixed width of columns of inputs
如何使用固定宽度的输入列生成对称的.txt文件
1 个解决方案
#1
1
You might be looking for setw width manipulator function provided by <iomanip>
header file and using it before or after or however you want to write each entry to the file.
您可能正在寻找由
#1
1
You might be looking for setw width manipulator function provided by <iomanip>
header file and using it before or after or however you want to write each entry to the file.
您可能正在寻找由