Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Easy Question

Reply
Thread Tools

Easy Question

 
 
Kandy
Guest
Posts: n/a
 
      10-15-2004
I allocated some memory with malloc
ligneb[indx]=(short*) malloc ((strlen(buffer)*+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 =---
 
Reply With Quote
 
 
 
 
JKop
Guest
Posts: n/a
 
      10-15-2004
Kandy posted:

> I allocated some memory with malloc
> ligneb[indx]=(short*) malloc ((strlen(buffer)*+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
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      10-15-2004
Kandy wrote:
> I allocated some memory with malloc
> ligneb[indx]=(short*) malloc ((strlen(buffer)*+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
 
Reply With Quote
 
JKop
Guest
Posts: n/a
 
      10-15-2004
Victor Bazarov posted:

> Kandy wrote:
>> I allocated some memory with malloc
>> ligneb[indx]=(short*) malloc ((strlen(buffer)*+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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it reasonably easy easy to something like this with python? Bruno Desthuilliers Python 5 08-29-2007 07:40 AM
Stripping audio from qa DVD. Easy or not so easy? GJ Computer Support 1 05-23-2007 02:03 AM
Shared folders - easy question JLunis Wireless Networking 7 03-11-2005 11:33 PM
easy to look at and easy to maintain web page menuing system. Hazzard ASP .Net 2 04-06-2004 03:51 AM



Advertisments