PLEASE HELP. Storing data from text file into array of structures *****SOLVED*****
Hello. Any help would be greatly appreciated. I an trying to store each line of text in a text file into array of structures, so that I can sort the data later on but it is not working. Here is an example of how the text file is layed out. Web Developer // JobTitle 7 // NumSkills PHP // Skills v HTML CSS Javascript jQuery JSON SQL 60000 // Salary Knox County Government // Company I want to store Web Developer into an array of jobs.jobTitle the next line I would like to store into jobs.NumSkills, and then I would like to loop depending on what is it NumSkills. and store that information into jobs.Skills, once the loop is finished I would like to store the next line into Salary, the next into Company. It is not working as JobTitle holds more than it should. Here is what I have for my loop. while (!in_stream.eof() && (count < MAX_LENGTH)){ in_stream.getline(jobs[count].jobTitle, MAX_LENGTH, '\0'); in_stream >> jobs[count].numSkills; for(int i = 0; i < jobs[count].numSkills; i++){ in_stream >> jobs[count].skills[i]; } in_stream >> jobs[count].salary; in_stream >> jobs[count].company; ++count; } I have got the whole code posted on Code Playground. https://code.sololearn.com/cGd0l3g25coL