Hello !
I have array of struct and i want
1] when i run the program to load the data from it.
2] when i make changes to be saved in the text file the same time or when i quit the program
I tried to put data in txt file with the following format but i can only read until the space. I do a lot of search but wasn`t able to find what i look for. Mainly i don`t know how to read strings
A1 false Alexa Trina
A2 falseGeorge Ali
A3 false Comina Riviera
My sample code is:
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
class classroom
{
public:
string studentClass;
bool studentBonus;
string studentName;
void classroom::createStudent(string sClass, bool bonus, string name);
};
void classroom::createStudent(string sClass, bool bonus, string name)
{
studentClass=sClass;
studentBonus=bonus;
studentName=name;
}
int main()
{
//number of students
const int numstudents=10;
//create structure
classroom student[numstudents];
//initialize variables
student[0].createStudent("A1",false,"Alexa Trina");
student[1].createStudent("A2",false,"George Ali");
student[2].createStudent("A3",false,"Comina Riviera");
return 0;//indicate that program end succesfully
}//end main
Thanks for your time!