Question

char f[4][50];
 for (int j = 0; j < 4; j++){
    cin>>f[j];
    Courses[i].setFields((char**)&f);
    file.write((char*)(Courses[i].getFeild()),50);
    }   

this piece of code gives run time error any help ?

Was it helpful?

Solution

You have declared f as

char f[4][50];

So essentially, f is a pointer to a pointer to the first character to the first string in an array. So you don't need an ampersand before f in:

Courses[i].setFields((char**)f)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top