Error of "*** Break *** segmentation violation"

my program is giving the Segmentation violation error. Please could you help me figure the error.

ifstream in;
    in.open("Temperature01-12-2021-09-12-2021.txt");
    int lincent;
    float date_index;
    double temperature;
    vector <float> date;
    vector <float> temp;
    ULong64_t first_timestamp;
    ULong64_t last_timestamp;
    TCanvas* mianCanvas = new TCanvas("miancanvas");
    while(!in.eof())
    {
        in>>date_index>>temperature;
        lincent++;
        date.push_back(date_index);
        temp.push_back(temperature);
    }
    printf("%d", lincent);
    TGraph* graph = new TGraph(lincent);
    graph->SetMarkerStyle(7);
    graph->SetMarkerColor(kRed);
    graph->SetLineColor(kRed);
    graph->GetXaxis()->SetTimeDisplay(1);
    graph->GetXaxis()->SetTimeFormat("%Y-%m-%d %H:%M:%S %F 1970-01-01 00:00:00");
    first_timestamp = (date.data())[0];
    last_timestamp = (date.data())[lincent-1];
    TTimeStamp first_ts(first_timestamp);
    TTimeStamp last_ts(last_timestamp);
    for(int i = 0; i < lincent; i++)
    {
      graph->SetPoint(i, (date.data())[i], (temp.data())[i]);
    }
    graph->SetTitle(Form("%d-%d", first_ts.GetDate(), last_ts.GetDate()));
    graph->GetXaxis()->SetTitle("Time");
    graph->GetYaxis()->SetTitle("Current (A)");

    graph->Draw("ALP");
    return 0;

        // ...
        lincent++;
        cout << lincent << endl;
        // ...

it didn’t solve the issue. Still shows same Break Segmentation error

Read the output of that and find the problem.

I guess the problem is that you didn’t initialize your variable:

    int lincent;
    float date_index;
    double temperature;

should be

    int lincent = 0;
    float date_index = 0.0;
    double temperature = 0.0;

(for the float and double, it doesn’t matter because you are reading them later from file, but it’s good practice to always define your variables).