Hey everyone new to the board and in a bit of bother.

I've got this assignment thats been plaging me for two weeks but i can't do this one bit as i just don't get it.

I've got to write a programme that takes data in from a file and inserts them into arrays. the array is set up through a strut.

I should then be able to add,delete,amend,or list the data on the screen in certain orders.

now all this is O.K. i understand all this and can do this but i don't know how to dynamically resized an array if the array gets full ! :confused:
I've been scraching my head now for two weeks and nothing is going on will some one please take the time too explain how to implement this i would be very greatfull.:cheesy: :cheesy:

All those pointers get me confused PLUS not aloud to use VECTORS or old C malloc etc

thanks steve

p.s. great board

Like you start with

int size = 10;
int *array = new int[size];

And to make it bigger,

int *bigger = new int[size+10];
// some stuff
delete [ ] array;
array = bigger;

What goes in "some stuff" is an exercise for the reader ;)

Sorry now but still not sure how to implement it into my programme:confused: rough example follows::::

#define MAX_PERSONS 100
 
 
struct array
{
    string name;
    
    int account; 
    
    double balance;
    
};
 
typedef  array ARRAY;   
 
 
ARRAY valu[MAX_PERSONS];
 
void add_account(ARRAY package_info[]);
 
 
int menu();
 
{
case 1 :   add_account(valu);
               break;
 
case 2 :   delete(valu);
               break;
 
case 3 :    amend(valu):
                break;
 
case 4 :    list(valu);
                break;
 
}

int menu();
{
 
BLA BLA BLA BLA
}
 
 
void add_account(ARRAY package_info[])
{
 
search array for freespace
 
   if no free space RESIZE
 
  else input data
 
 
}

Assume that the array is a fixed size (ie, a regular array), and write some code to put data into it.

Turning it into a variable length array (once you've done that) is only a few lines of code.

At least it allows you to focus on one issue at a time.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.