fstream - fix the column width in .txt file using c++ -
i have created 1 class of doctor , want insert data of doctor in note pad file (doctor.txt) data not have symmetry because there no fixed length of inputs in line...
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 generate symmetrical .txt file using fixed width of columns of inputs
you might looking setw width manipulator function provided <iomanip>
header file , using before or after or want write each entry file.
Comments
Post a Comment