[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] Hvilket sprog



donald_j_axel wrote:
On Wed, 30 Jun 2004 11:10:00 +0200
Egon Andersen <sslug@sslug> wrote:


En af de store nyheder i ISO-C99, er netop at variabler kan erklæres i block-scope, så ovenstående virker faktisk hvis du anvender ISO-C99!


Det er en ofte set fejltagelse, at variable ikke kunne erklæres i
block scope i "K&R-C"

det har altid været tilladt at skrive

int main(int argc, char *argv[])
{
    printf("Start\n");
    {
       int y;
       for (y=1; y<10; ++y) {
          printf("Meter: %d    Nordsjællandske fod %f\n", y, 3.123456 * y);
       }
    }  /* --------------  here endeth scope of variable y */
    printf("Slut\n");
}

Det nye er, at du må lave "int y=1" ***INDE*** i for-løkken.


Da jeg ikke har hverken K&R eller ISO-C89, men kun ISO-C99, og da det heller ikke står beskrevet som noget nyt i ISO-C99, at variabler kan erklæres i blok-scope, må jeg antage at din udtalelse mht. K&R er korrekt.
Det nye i ISO-C99, i denne sammenhæng, er:
"New block scopes for selection and iteration statements"
Dvs. if/switch/for/while.


Og så er der mange andre forbedringer i ISO-C99 i forhold til ISO-C89 - andre kan have andre meninger om dette, men jeg har altid haft stor glæde af ISO-C99 i forhold til ISO-C89.

Med venlig hilsen
Egon Andersen


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