[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] Kode der aldrig bliver kxrt?



On Thu, 17 Aug 2000, Bjarke Bruun wrote:


> Takker for rettelsen - lang dag... 

Den er vist da ikke slut endnu.

> 
> > Bortset fra det, har jeg aldrig hørt om at int arrays i C++ er afsluttet
> > med \0, altså at der allokeres flere pladser til int sum[2] end til int a,
> > int b.
> > 
> > Det lyder dybt underligt.
> 
> Vi er enige om at char ch[5] giver ch[0] -> ch[4] som alm brug - ikk?

Jo

> kompilerern laver dog stadig et array der har 0-5 pladser hvilket vil

Nej, det er muligt at gcc på en intel processor vil gøre dette, men det er
ikke hvad C++ standarden definerer, svjv.

char ged = "MADS";
vil give 5 pladser.
char ged[5] vil give 5 pladser, ikke 0-5 pladser, som er 6.

> sige at ch[5] er '\0' iflg. kompileren og at man, hvis man laver en
> "cout << ch;" så vil programmet start med ch[0] og gå igennem til den
> møder det første '\0' tegn, ikk?

Jow, derfor man kan lave fejl. 

> 
> Med int arrys kan du ikke nulterminere da nul også er en valid talværdi
> derfor kan man benytte hele arrayet int a[5] giver derfor 6 pladser i
> arrayet 0->5.
> 

Dette er noget vrøvl.

På intel gcc i den nuværende version placerer den tilsyneladende
variable på en måde der giver noget luft (ledig lager) i det program
du giver som eksempel. Det vil være en fejl på mange andre platforme, og
i det hele taget.

Mads

-- 
Mads Bondo Dydensborg.                               sslug@sslug
You know you're a Linux geek when...

    You find the thought of rebooting after installing a piece of software
    utterly absurd.
                              
			                          - segfault



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

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