[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?



Mads Bondo Dydensborg wrote:
> 
> On Thu, 17 Aug 2000, Bjarke Bruun wrote:
> 
> 
> Du beviser ikke noget ved at oversætte eller køre ovenstående. Der er
> nemlig en fejl i... vil jeg da tro. Du mener snarere:
> 
> > #include <iostream>
> > void main()
> > {
> >   int sum[2];
> >   for (int x=0;x<3;x++)
> >     sum[x]=x;
> >   for (int x=0;x<3;x++)
> >     cout << sum[x] << endl;
> > }
> 

Takker for rettelsen - lang dag... 

> 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?
kompilerern laver dog stadig et array der har 0-5 pladser hvilket vil
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?

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.

Håber det forklare dette "underlige" problem.

-- 
Bjarke Bruun - E-mail: sslug@sslug http://linux.hhknet.dk
   __
  / /  (_)__  __ ____  __
 / /__/ / _ \/ // /\ \/ /  . . .  t h e   c h o i c e   o f   a
/____/_/_//_/\_,_/ /_/\_\              G N U   g e n e r a t i o n . . .


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