I am trying to display text file backwards line by line. I want to do this with char and dynamic allocation. I allocate a 2d dynamic array for this purpose. But the problem is that every line I read in the erase the precedent. This is my code :
int main()
{
    char path[256]; string name;
    cout << "Enter path:" << endl; cin >> path;
    ifstream file(path);
    if (!file) { cout << "ERROR" << endl; return -1; }
    char** sentence = new char* [100];
    for (int i = 0; i < 100; i++)
        *sentence = new char[120];
    char line[120];
    int index = 0;
    while(!file.eof())
    {
        file.getline(line, 120);  
        sentence[index++] = line; //Erase precedent line
    }
    for (int i = 0; i < index; i++)
        cout << sentence[i] << endl;
    
    return 0; 
}
 
     
    