structure and pointers

N

nemesia31

i have a structure
typedef struct tm
{
int date;
int hour;
int minutes;
} time;

i want to use this structure dynamically, ie, i want it to grow.

like it would be
time *sept= new time;
sept->date=15;
......
.........
.......
but i want something like

for(int i=0;i<MAX;i++)
{
sept->date=i+5;
}

i want to grow the structure dynamically, ie, the valur of MAX is
provided at runtime.
how can i do tht????
 
K

Kai-Uwe Bux

i have a structure
typedef struct tm
{
int date;
int hour;
int minutes;
} time;

i want to use this structure dynamically, ie, i want it to grow.

like it would be
time *sept= new time;
sept->date=15;
.....
........
......
but i want something like

for(int i=0;i<MAX;i++)
{
sept->date=i+5;
}

i want to grow the structure dynamically, ie, the valur of MAX is
provided at runtime.
how can i do tht????


Sounds like std::vector< tm > might be what you need. Read up on the
standard library and in particular the standard containers.


Best

Kai-Uwe Bux
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top