HAving trouble with my pointer arithmetic, any ideas appreciated
My orgional code
Activity p[51];
for ( int i = 1; i <= n; ++i ) {
// Read the activity records.
pert >> p[i].i >> p[i].j >> p[i].pt
>> p[i].prt >> p[i].ot;
pert.getline(p[i].desc,21);
converted but wrong
Activity **p = new Activity*[51];
for ( i = 1; i <= n; ++i ) {
if (p[i].i == NULL)
break;
pert >> (*p+i)->i >> *(p+i)->j >> *(p+i)->pt
>> *(p+i)->prt >> *(p+i)->ot;
pert.getline(*(p+i)->desc,21);
}
my struct
struct Activity {
int i, // Beginning node number.
j; // Ending node number.
float pt, // Pessimistic time.
prt, // Most probable time.
ot; // Optimistic time.
char desc[21]; // Activity description.
};
if you want the whole code let me know