[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: [PROGRAMMERING] Bog om C



On Wed, 12 May 2004 11:29:12 +0200, henrik wrote:

> 
> På novice-niveau siger du? Tak skal du have! Nå,
Nu var det ikke en henvisning til, at du er novice. Blot en oplysning til
dig om, at du ikke havde grund til at anskaffe den, hvis du selv mente,
du var over novice stadiet:-)
> faktisk har jeg et novicespørgsmål: Jeg
har set i C-kode at strukturer
> af variabel størrelse defineres noget lignende sådan her: struct text
> {
>     int length;
>     char data[1];
> };
> hvor data så kan have hvilken som helst længde. Er der nogen som kan
> sige mig hvordan det fungerer og hvad fidusen er med denne konstruktion?
> Hvorfor ikke ... char *data; ...?
> 
En god grund kunne være, at struct's selv reserverer den nødvendige
hukommelse, der er behov for, så hvis længde sættes til 10, vil struct
have længden 10 + 1 bytes (char data[1], der så kan bruges til '\0').

-- 
Hilsen/Regards
Michael Rasmussen
--------------------------------------------------------------
Bridge ahead.  Pay troll.




 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 22:43 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] *