• Re: Loops (was Re: do { quit; } else { })

    From Tim Rentsch@tr.17687@z991.linuxsc.com to comp.lang.c on Tue Jun 10 06:01:20 2025
    From Newsgroup: comp.lang.c

    Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:

    Kaz Kylheku <643-408-1753@kylheku.com> writes:
    [...]

    Progarms that manipulate strings using standard library functions
    often take advantage of the above. Strings are defined as
    null-terminated arrays; but it is very common for strings to be
    arrays that are displaced within larger arrays.

    To be pedantic, a string is defined as "a contiguous sequence of
    characters terminated by and including the first null character".
    The word "array" is not used. It does seem fairly obvious that
    the contiguous sequence will be stored in an array (array
    object?), but the standard doesn't quite say so.

    Consider the following program:

    #include <stdio.h>
    #include <string.h>

    typedef unsigned long long ULL;
    ULL hello = ((((0ULL +'o' <<8) +'l' <<8) +'l' <<8) +'e' <<8) + 'h';

    int
    main(){
    printf( "length is %zu\n", strlen( (char*)&hello ) );
    return 0;
    }

    On a little endian machine (with CHAR_BIT == 8) this program works,
    and TTBOMK conforms to both the letter and the spirit of the C
    standard, without any undefined behavior (on that platform). Yet
    there are no arrays in sight, and certainly no array objects.
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Bonita Montero@Bonita.Montero@gmail.com to comp.lang.c on Sat Jun 14 12:24:30 2025
    From Newsgroup: comp.lang.c

    Am 10.06.2025 um 15:01 schrieb Tim Rentsch:

    Consider the following program:

    #include <stdio.h>
    #include <string.h>

    typedef unsigned long long ULL;
    ULL hello = ((((0ULL +'o' <<8) +'l' <<8) +'l' <<8) +'e' <<8) + 'h';

    int
    main(){
    printf( "length is %zu\n", strlen( (char*)&hello ) );
    return 0;
    }

    On a little endian machine (with CHAR_BIT == 8) this program works,
    and TTBOMK conforms to both the letter and the spirit of the C
    standard, without any undefined behavior (on that platform). Yet
    there are no arrays in sight, and certainly no array objects.

    There are not much remaining big-endian architectures today.
    Little-endian is simply the cleverer idea.

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From scott@scott@slp53.sl.home (Scott Lurndal) to comp.lang.c on Sat Jun 14 13:57:56 2025
    From Newsgroup: comp.lang.c

    Bonita Montero <Bonita.Montero@gmail.com> writes:
    Am 10.06.2025 um 15:01 schrieb Tim Rentsch:

    Consider the following program:

    #include <stdio.h>
    #include <string.h>

    typedef unsigned long long ULL;
    ULL hello = ((((0ULL +'o' <<8) +'l' <<8) +'l' <<8) +'e' <<8) + 'h';

    int
    main(){
    printf( "length is %zu\n", strlen( (char*)&hello ) );
    return 0;
    }

    On a little endian machine (with CHAR_BIT == 8) this program works,
    and TTBOMK conforms to both the letter and the spirit of the C
    standard, without any undefined behavior (on that platform). Yet
    there are no arrays in sight, and certainly no array objects.

    There are not much remaining big-endian architectures today.

    Ethernet is big-endian at the byte level and little-endian
    at the bit level.

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Michael S@already5chosen@yahoo.com to comp.lang.c on Sat Jun 14 22:27:20 2025
    From Newsgroup: comp.lang.c

    On Sat, 14 Jun 2025 13:57:56 GMT
    scott@slp53.sl.home (Scott Lurndal) wrote:

    Bonita Montero <Bonita.Montero@gmail.com> writes:
    Am 10.06.2025 um 15:01 schrieb Tim Rentsch:

    Consider the following program:

    #include <stdio.h>
    #include <string.h>

    typedef unsigned long long ULL;
    ULL hello = ((((0ULL +'o' <<8) +'l' <<8) +'l' <<8) +'e' <<8) +
    'h';

    int
    main(){
    printf( "length is %zu\n", strlen( (char*)&hello ) );
    return 0;
    }

    On a little endian machine (with CHAR_BIT == 8) this program works,
    and TTBOMK conforms to both the letter and the spirit of the C
    standard, without any undefined behavior (on that platform). Yet
    there are no arrays in sight, and certainly no array objects.

    There are not much remaining big-endian architectures today.

    Ethernet is big-endian at the byte level and little-endian
    at the bit level.


    802.3 frames are big-endian, because of Length field.
    Several orders of magnitude more popular Ethernet II frames are
    endian-neutral.

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Bonita Montero@Bonita.Montero@gmail.com to comp.lang.c on Sun Jun 15 09:32:39 2025
    From Newsgroup: comp.lang.c

    Am 14.06.2025 um 15:57 schrieb Scott Lurndal:
    Bonita Montero <Bonita.Montero@gmail.com> writes:
    Am 10.06.2025 um 15:01 schrieb Tim Rentsch:

    Consider the following program:

    #include <stdio.h>
    #include <string.h>

    typedef unsigned long long ULL;
    ULL hello = ((((0ULL +'o' <<8) +'l' <<8) +'l' <<8) +'e' <<8) + 'h'; >>>
    int
    main(){
    printf( "length is %zu\n", strlen( (char*)&hello ) );
    return 0;
    }

    On a little endian machine (with CHAR_BIT == 8) this program works,
    and TTBOMK conforms to both the letter and the spirit of the C
    standard, without any undefined behavior (on that platform). Yet
    there are no arrays in sight, and certainly no array objects.

    There are not much remaining big-endian architectures today.

    Ethernet is big-endian at the byte level and little-endian
    at the bit level.

    However, little-endian is simply the smarter concept.
    --- Synchronet 3.21a-Linux NewsLink 1.2