🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: alt.comp.lang.learn.c-c++
9 messages
9 total messages Started by Warren S. Wyght Tue, 09 Jan 2001 20:25
Find size of Array?
#42
Author: Warren S. Wyght
Date: Tue, 09 Jan 2001 20:25
14 lines
1732 bytes
How do I find the size of an Array once the array was created by either
malloc or new.

Warren

--
Society is produced by our wants, and government by our wickedness;
the former promotes our POSITIVELY by uniting our affections,
the latter NEGATIVELY by restraining our vices. The one encourages
intercourse,
the other creates distinctions. The first a patron, the last a punisher.
COMMON SENSE
Thomas Paine
Philadelphia, February 14, 1776
Re: Find size of Array?
#43
Author: Ron Natalie
Date: Tue, 09 Jan 2001 20:30
9 lines
1561 bytes

"Warren S. Wyght" wrote:
> 
> How do I find the size of an Array once the array was created by either
> malloc or new.
> 
You can't.  You must remember what it was when you created it.
Alteratively, bag using new to allocate arrays and use vector.
Re: Find size of Array?
#44
Author: Jon Bell
Date: Tue, 09 Jan 2001 20:31
13 lines
1655 bytes
 Warren S. Wyght <wswyght@telusplanet.net> wrote:
>How do I find the size of an Array once the array was created by either
>malloc or new.

You can't.  You have to keep track of it yourself.  Or, instead of using
an array, use std::vector or std::string, both of which keep track of
their sizes, and can tell it to you via the size() member function.

-- 
Jon Bell <jtbell@presby.edu>                         Presbyterian College
Dept. of Physics and Computer Science         Clinton, South Carolina USA
[   Help try to keep the Deja.com archive alive!  Sign the petition at  ]
[         http://www2.PetitionOnline.com/dejanews/petition.html         ]
Re: Find size of Array?
#45
Author: Warren S. Wyght
Date: Tue, 09 Jan 2001 20:45
29 lines
2562 bytes
I see I am going to have to read up on vectors.

Thanks for your help



--
Society is produced by our wants, and government by our wickedness;
the former promotes our POSITIVELY by uniting our affections,
the latter NEGATIVELY by restraining our vices. The one encourages
intercourse,
the other creates distinctions. The first a patron, the last a punisher.
COMMON SENSE
Thomas Paine
Philadelphia, February 14, 1776
Jon Bell <jtbell@presby.edu> wrote in message news:G6wx0D.Cvs@presby.edu...
> Warren S. Wyght <wswyght@telusplanet.net> wrote:
> >How do I find the size of an Array once the array was created by either
> >malloc or new.
>
> You can't.  You have to keep track of it yourself.  Or, instead of using
> an array, use std::vector or std::string, both of which keep track of
> their sizes, and can tell it to you via the size() member function.
>
> --
> Jon Bell <jtbell@presby.edu>                         Presbyterian College
> Dept. of Physics and Computer Science         Clinton, South Carolina USA
> [   Help try to keep the Deja.com archive alive!  Sign the petition at  ]
> [         http://www2.PetitionOnline.com/dejanews/petition.html         ]
Re: Find size of Array?
#46
Author: Warren S. Wyght
Date: Tue, 09 Jan 2001 20:45
24 lines
2160 bytes
I see I am going to have to read up on vectors.

Thanks for your help

--
Society is produced by our wants, and government by our wickedness;
the former promotes our POSITIVELY by uniting our affections,
the latter NEGATIVELY by restraining our vices. The one encourages
intercourse,
the other creates distinctions. The first a patron, the last a punisher.
COMMON SENSE
Thomas Paine
Philadelphia, February 14, 1776
Ron Natalie <ron@spamcop.net> wrote in message
news:3A5B74F9.D9D3225@spamcop.net...
>
>
> "Warren S. Wyght" wrote:
> >
> > How do I find the size of an Array once the array was created by either
> > malloc or new.
> >
> You can't.  You must remember what it was when you created it.
> Alteratively, bag using new to allocate arrays and use vector.
Re: Find size of Array?
#47
Author: Donovan Rebbechi
Date: Tue, 09 Jan 2001 22:22
13 lines
1700 bytes
On Tue, 09 Jan 2001 20:25:16 GMT, Warren S. Wyght wrote:
>How do I find the size of an Array once the array was created by either
>malloc or new.

You don't. You need to keep track of the size. That's why data structures
like vector and string have fields that keep track of this information.

Of course, if you use vector<> instead of a pointer array, you can just use
the size() method.

-- 
Donovan Rebbechi * http://pegasus.rutgers.edu/~elflord/ * 
elflord at panix dot com
Re: Find size of Array?
#48
Author: Flavius Vespasian
Date: Tue, 09 Jan 2001 23:30
21 lines
2150 bytes
In article <MsK66.2480$FH5.269435@news0.telusplanet.net>, "Warren S. Wyght" <wswyght@telusplanet.net> wrote:
>How do I find the size of an Array once the array was created by either
>malloc or new.

This is why you should use the vector classes in the standard library.

John - N8086N 
Big brother is watching. Disable cookies in your web browser.
-------------------------------------------
Wise man says "Never use a bank with the initials F. U."
-------------------------------------------
Are you interested in a professional society or
guild for programmers? Want to fight section 1706?


See www.programmersguild.org
Newsgroup: us.issues.occupations.computer-programmers


EMail Address:
_m-i-a-n-o_@_c_o_l_o_s_s_e_u_m_b_u_i_l_d_e_r_s._c_o_m_
Re: Find size of Array?
#49
Author: Martin Ambuhl
Date: Wed, 10 Jan 2001 07:27
6 lines
1711 bytes
"Warren S. Wyght" wrote:
> 
> How do I find the size of an Array once the array was created by either
> malloc or new.

You remember it.  Do your own bookkeeping.
Re: Find size of Array?
#63
Author: Mr Pete
Date: Sun, 17 Jun 2001 13:18
44 lines
2829 bytes
also (i'm new) the vector deletes itself automatically which saves loads

Mr Pete



Warren S. Wyght <wswyght@telusplanet.net> wrote in message
news:xLK66.2546$FH5.272485@news0.telusplanet.net...
> I see I am going to have to read up on vectors.
>
> Thanks for your help
>
>
>
> --
> Society is produced by our wants, and government by our wickedness;
> the former promotes our POSITIVELY by uniting our affections,
> the latter NEGATIVELY by restraining our vices. The one encourages
> intercourse,
> the other creates distinctions. The first a patron, the last a punisher.
> COMMON SENSE
> Thomas Paine
> Philadelphia, February 14, 1776
> Jon Bell <jtbell@presby.edu> wrote in message
news:G6wx0D.Cvs@presby.edu...
> > Warren S. Wyght <wswyght@telusplanet.net> wrote:
> > >How do I find the size of an Array once the array was created by either
> > >malloc or new.
> >
> > You can't.  You have to keep track of it yourself.  Or, instead of using
> > an array, use std::vector or std::string, both of which keep track of
> > their sizes, and can tell it to you via the size() member function.
> >
> > --
> > Jon Bell <jtbell@presby.edu>                         Presbyterian
College
> > Dept. of Physics and Computer Science         Clinton, South Carolina
USA
> > [   Help try to keep the Deja.com archive alive!  Sign the petition
t  ]
> >
  http://www2.PetitionOnline.com/dejanews/petition.html         ]
>
>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads