[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] Bestemme længde af strengpå compile-time



Anders Melchiorsen <sslug@sslug> skrev:


>Mads Bondo Dydensborg <sslug@sslug> skrev:

>> Bemærk at det (åbenbart) er mere korrekt at skrive sizeof foo

>Det er vist samme snak som om det hedder
>
>        return a;
>
>eller
>
>        return(a);

Ikke helt
Det er altid fuldt legalt at omkranse "a unary expresion" med paranteser - 
hvad der til gengæld ikke er legalt er at undlade brug af paranteser ved 
onkring "type-name" ved sizeof.

EX1:
void bar()
{
  const char foo[]= "ab";
  printf("sizeof foo:  %i\n", sizeof foo);    // OK foo is a unary 
expresion
  printf("sizeof(foo): %i\n", sizeof(foo));  // OK foo is still a unary 
expression
}
EX2:
void bar()
{
  typedef char foo;
  printf("sizeof foo:  %i\n", sizeof foo);    // ERROR: foo is not a unary 
expresion
  printf("sizeof(foo): %i\n", sizeof(foo));  // OK foo is a type-name
}

min pointe var at "sizeof foo" tydeliggør at der ikke kan være tale om et 
type-navn.

mvh.
Nils Åke Ljunggren


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

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