[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] Array af pointere til strukturer



On Thu, 2003-03-13 at 09:39, Hans-Christian Stadler wrote:
> Henrik Brix Andersen wrote:
> > FooBar **get_foobars (void)
> > {
> >   FooBar **foo;
> >   int n;
> > 
> >   n = /* beregn n */
> > 
> >   info = malloc (sizeof(FooBar) * n + 1);
> Jeg tror, at du er ude på at gøre det sådan her:
> foo = malloc(sizeof(*foo) * n + 1);

Ja, selvfølgelig - det var bare navngivningen fra den reelle kildetekst,
der skinnede igennem. ;)

> Hvis du skal fylde noget i foo[i] her, skal du huske, at udføre
> foo[i] = malloc(sizeof(FooBar)) først.

Ja, det er jeg med på... men tak for påmindelsen.

> Tilgang sker sådan: foo[i]->bar = ...
> 
> Så passer resten af koden her også fint.

Mange tak, det ser ud til at virke som jeg havde tænkt mig. :)

Også tak til alle jer, der havde andre forslag til hvordan jeg kunne
gøre ovenstående.

Mvh
./Brix
-- 
Henrik Brix Andersen <sslug@sslug>



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:09 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *