Easy Question

Discussion in 'C++' started by Kandy, Oct 15, 2004.

  1. Kandy

    Kandy Guest

    I allocated some memory with malloc
    ligneb[indx]=(short*) malloc ((strlen(buffer)*8)+1);

    but know I need to insert the single value inside
    ligneb[0] I need to insert all my binary value

    How can I increase the position?
    How can I jump to any position?

    Thank you




    ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
    ---= East/West-Coast Server Farms - Total Privacy via Encryption =---
     
    Kandy, Oct 15, 2004
    #1
    1. Advertising

  2. Kandy

    JKop Guest

    Kandy posted:

    > I allocated some memory with malloc
    > ligneb[indx]=(short*) malloc ((strlen(buffer)*8)+1);
    >
    > but know I need to insert the single value inside
    > ligneb[0] I need to insert all my binary value


    As with all languages, English is no different in that one must must specify
    to which particular article they are referring before they may actually use
    the definite article indicator, ie. "the". "the single value" is undefined.
    Improve your grammar and try again.


    > How can I increase the position?



    Once again, "the position" is undefined.


    > How can I jump to any position?




    As above.


    -JKop
     
    JKop, Oct 15, 2004
    #2
    1. Advertising

  3. Kandy wrote:
    > I allocated some memory with malloc
    > ligneb[indx]=(short*) malloc ((strlen(buffer)*8)+1);
    >
    > but know I need to insert the single value inside
    > ligneb[0] I need to insert all my binary value
    >
    > How can I increase the position?
    > How can I jump to any position?


    I have no idea what you're talking about. What is 'ligneb'?
    What single value are you inserting into 'ligneb[0]'? How
    was 'ligneb[0]' allocated?

    If you need to increase the length of a dynamic array that
    was allocated using 'malloc', use 'realloc'.

    In most cases, if you're trying to use C++, malloc and any
    other C memory management functions just don't cut it. Neither
    do 'new' and 'delete', for beginners, anyway. Try using the
    standard containers. E.g., instead of

    short *ligneb[somany];

    do

    std::vector<std::vector<short> > ligneb(somany);

    and anything growing from that...

    Get a good C++ book.

    V
     
    Victor Bazarov, Oct 15, 2004
    #3
  4. Kandy

    JKop Guest

    Victor Bazarov posted:

    > Kandy wrote:
    >> I allocated some memory with malloc
    >> ligneb[indx]=(short*) malloc ((strlen(buffer)*8)+1);
    >>
    >> but know I need to insert the single value inside
    >> ligneb[0] I need to insert all my binary value
    >>
    >> How can I increase the position?
    >> How can I jump to any position?

    >
    > I have no idea what you're talking about. What is 'ligneb'?
    > What single value are you inserting into 'ligneb[0]'? How
    > was 'ligneb[0]' allocated?
    >
    > If you need to increase the length of a dynamic array that
    > was allocated using 'malloc', use 'realloc'.
    >
    > In most cases, if you're trying to use C++, malloc and any
    > other C memory management functions just don't cut it. Neither
    > do 'new' and 'delete', for beginners, anyway. Try using the
    > standard containers. E.g., instead of
    >
    > short *ligneb[somany];
    >
    > do
    >
    > std::vector<std::vector<short> > ligneb(somany);
    >
    > and anything growing from that...
    >
    > Get a good C++ book.
    >
    > V




    Don't feed the trolls!


    -JKop
     
    JKop, Oct 15, 2004
    #4
    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. Mike
    Replies:
    1
    Views:
    2,158
  2. Replies:
    2
    Views:
    482
    Ralf Hildebrandt
    May 2, 2005
  3. Mike King

    Easy RegEx Question

    Mike King, Apr 12, 2005, in forum: Perl
    Replies:
    1
    Views:
    2,613
    Mike King
    Apr 13, 2005
  4. Hazzard
    Replies:
    2
    Views:
    652
    Hazzard
    Apr 6, 2004
  5. Bruno Desthuilliers
    Replies:
    5
    Views:
    395
    Bruno Desthuilliers
    Aug 29, 2007
Loading...

Share This Page