structure and pointers

Discussion in 'C++' started by nemesia31@gmail.com, Sep 27, 2006.

  1. Guest

    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????
     
    , Sep 27, 2006
    #1
    1. Advertising

  2. Kai-Uwe Bux Guest

    wrote:

    > 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
     
    Kai-Uwe Bux, Sep 27, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roger Leigh
    Replies:
    8
    Views:
    474
    Karl Heinz Buchegger
    Nov 17, 2003
  2. Excluded_Middle

    Pointers to structure and array of structure.

    Excluded_Middle, Oct 24, 2004, in forum: C Programming
    Replies:
    4
    Views:
    794
    Martin Ambuhl
    Oct 26, 2004
  3. Replies:
    9
    Views:
    25,545
    Lal Bahadur Singh
    Nov 11, 2011
  4. cerr

    pointers, pointers, pointers...

    cerr, Apr 7, 2011, in forum: C Programming
    Replies:
    12
    Views:
    737
  5. A
    Replies:
    27
    Views:
    1,678
    Jorgen Grahn
    Apr 17, 2011
Loading...

Share This Page