LF Help with a program

10/12/2015 19:44 Dwarfche#1
My task is the following:

For every foreign tourist who visited our country in x year, collect the following information:
-name
-sex
-country
-ages
-profession

The program must save all this following info in a text file and also to be possible to export the following info:
-average age of the tourists
-the name and country of the youngest woman
-from which country there are most students

will be really thankful if sm1 can help me with parts or the whole program or the algorythm. Answer on the thread/PM or add me on skype
10/22/2015 18:48 Cyrex'#2
1. check if the x'th year is reached
2. gather his information somehow(you didnt tell) and save it into a string vector
3. use fstream header apis to create a file, a file stream and then write to it

e.g.

PHP Code:
int main(void)
{
    if(!
NthYearIsReached())
        return 
0;
    
    
std::vector<stringinfo;
    [...] 
//collect info with push_back()
    
    //output the vector with a range for to check if it saved everything
    
[...] // for(auto elem : info) {...}
    
    
    //if everything is correct
    
fstream file;
    
file.open("TouristInfo.txt"fstream::out);
    for(
auto elem info)
    {
        
file << elem << std::endl;
    }
    
    
file.close();
    
    return 
0;