How to read data from a .txt file into an array of structs..
The file contains data in a table storing Name, Sex, Address and phone number. The amount of lines of data is not known,data reading is terminated by a line containing "end" only.
1
Expert's answer
2018-04-09T13:16:10-0400
#include <iostream> #include <fstream> #include <string> #include <sstream> using namespace std; struct myStruct { public: int phoneNumber; string Address; string Sex; string Name; }; int main() { ifstream fin("input.txt"); string str; myStruct* my_Struct = new myStruct[1000]; int counter = 0; while (true) { getline(fin, str);
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments