[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
 

Initialiserings problem



Hej,

Jeg har nu en stund (eller to) bøvlet med initialisering af nogle
struktur variable.
Simplificeret er problemet kogt ned til et lille program som følger:
---
typedef struct{double f;} beta_t;

struct Alpha
   {
   beta_t * a;
   beta_t ** aa;
   };
const struct Alpha gamma = {.a = (beta_t[1]){{.f = 5.0}}};

/* Følgende linie er forkert, men hvordan skal den skrives ?? */
const struct Alpha delta = {.aa = (beta_t**)((beta_t[1][1]){{{.f =
8.7}}})};
   
main()
   {
   printf("Yep %f\n", *gamma.a);
   printf("Yep %p\n", gamma.aa);
   printf("Yep %p\n", delta.a);
   printf("Nope %f\n", **delta.aa);
   return 0;
   }
---

Problemet er at initialisere delta.aa, således at **delta.aa er 8.7
Jeg ønsker at undgå hjælpevariable, da det hele bliver en del af en
auto-genereret header-fil. Hjælpevariable vil potentielt give
navne-sammenfald.

Er der nogen der har et godt bud?

/Egon


 
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] *