I managed to isolate a bug that made the program to crash but I can't figure out the issue yet. I suppose the problem is in the call to the default constructors for the objects lookProfile and lookContacts, since, once I remove those lines the program runs smoothly.
This is the main.
#include <iostream>
#include <fstream>
#include "profile.h"
#include "contact.h"
#include <sstream>
using namespace std;
void Query(profile* &lsp,int,ofstream& outt);
int main()
{
    ifstream inn;
    ofstream outt;
    char resp;
    profile *listp;
    int length=0;
    listp = new profile[50];
    inn.open("profiles.txt");     // retrieve profiles
    retrieveProfiles(inn,listp,length);
    inn.close();
    cout << "Do you want to add your profile or to look for someone? (A/L)";
    cin >> resp;
    if(resp=='A')
    {
        outt.open("profiles.txt",ios::app);
        addProfile(outt);
        outt.close();
    }else if(resp=='L')
    {
        outt.open("contacts.txt",ios::app);
        Query(listp,length,outt);
        outt.close();
    }
    else
        cout << "Wrong Input";
    return 0;
}
void Query(profile* &lsp,int length,ofstream& outt)
{
    const int THRESHOLD = 3;
    string str;
    int num,numvec[3];
    int *overthreshold;
    int countOver=0;
    char dis;
    profile lookProfile;
    contact lookContact;
}
These are the private members of the class profile and implementation of constructor and destructor:
 private:
     std::string name;
     std::string surname;
     int age;
     std::string icolor;
     int height;
     std::string homeTown;
     std::string livingTown;
     std::string *hobby;
     int lenghob;
     int ID;
profile::profile() //ctor
{
    name="";
    surname="";
    age=0;
    height=0;
    icolor="";
    homeTown="";
    livingTown="";
    lenghob=0;
    ID=0;
}
profile::~profile() //dtor
{
    delete [] hobby;
}
These are the private members of the class contact and implementation of constructor and destructor:
 private:
     int date[3];
     std::string time;
     std::string place;
     std::string address;
     std::string *keywords;
     int lengthkw;
contact::contact()      //ctor
{
    for(int i=0;i<3;i++)
        date[i]=1;
    time="12:00-13:00";
    place="";
    address="";
    lengthkw=0;
}
contact::~contact()
{
     delete [] keywords; //dtor
}
Thanks in advance.
 
     
    