TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: James Macken
from: Michael Stapleton
date: 1993-09-10 22:13:00
subject: Re: Help Request Message: MALLOC

Hello James,

JM> >> If you declare a pointer to a char or structure:

JM> >> char *cp[];

JM> >> Since I am declaring a POINTER, must I declare a size NOW
JM> >> between the square brackets or will this be catered for when
JM> >> I MALLOC?

DN> > This declaration is for an array of pointers, not 'a pointer'.
DN> > Yes, it requires a size (how many pointers go into the array) if
DN> > it is the definition and not simply a declaration.

 The definition creates the space for the pointer array, then you
call malloc() or copy existing string addresses to initialize these
pointers.

JM> Okay that makes sense. But what if it was:

JM> (char *)cp[];

JM> In other words, if I have the syntax right, a pointer to an array of
JM> characters.Would I need a number in the square brackets?

 You can include the array size, if you want to. The syntax is

 char (*cp)[STRINGSIZE];

 However, such an object is virtually equivalent to

 char **cp;

 Hope this helps,

Michael Stapleton of Graphic Bits.

___I'm only here for the taglines.

--- Blue Wave/RA v0.7 Q-Blue

* Origin: The Three Amigas - better than two (3:713/615.0)
SEEN-BY: 54/54 99 711/401 430 807 808 809 932 934 712/627 713/111 317 601 611
SEEN-BY: 713/615 618 700 729 805 888 906 714/906
@PATH: 713/615 888 54/99 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.