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

> Karl Pálsson wrote:
> > 
> > Ja, det er en bug.
> 
> Nej det er ikke en bug - et int array på [2] er 0,1 og 2 - da plads [2]
> ikke behøver at være NULL (læs '\0') da '\0' er NULL = 0, derfor er det
> ikke en bug.
> 
> Dette lille program beviser det:
> 
> #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 << x << endl;
> }

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;
> }

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.

Mads

-- 
Mads Bondo Dydensborg.                               sslug@sslug
Free your mind and your desktop will follow....
                                     Linux - the choice of a GNU generation



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