[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



Mads Bondo Dydensborg <sslug@sslug>
23-09-02 17:13
Please respond to sslug-cprog

 
        To:     sslug@sslug
        cc: 
        Subject:        Re: [CPROG] Bestemme længde af streng på compile-time

>On Mon, 23 Sep 2002, Jonas Kongslund wrote:

>> er det så muligt at bestemme ... dets længde ... 
>> på compile-time?

>const char foo[] = "fluffer ged";
>int main () {
>  printf("sizeof *foo: %i\n", sizeof(foo));
>  printf("foo er %s", foo);
>  return 0;
>}
>...
>sizeof *foo: 12
>foo er fluffer ged

sizeof kommer i 2 versioner:
sizeof unary-expression
sizeof ( type-name )
(ISO/IEC 9899:1999(E))

Den første linie i funktion main() burde derfor hede:
        printf("sizeof foo: %i\n", sizeof foo);
for at tydeligøre at foo ikke er et typenavn.

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