Re: Suggested method for returning a string from a C program?

Liste des GroupesRevenir à cl c 
Sujet : Re: Suggested method for returning a string from a C program?
De : bc (at) *nospam* freeuk.com (bart)
Groupes : comp.lang.c
Date : 20. Mar 2025, 13:23:23
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vrh1br$35029$2@dont-email.me>
References : 1 2 3 4 5 6 7 8
User-Agent : Mozilla Thunderbird
On 20/03/2025 12:09, Tim Rentsch wrote:
Michael S <already5chosen@yahoo.com> writes:

I suspected that, but was not sure, so suggested to DFS a type that I am
sure about.
 The width of  char and [un]signed char   must be at least  8 bits.
The width of          [un]signed short   must be at least 16 bits.
The width of            [un]signed int   must be at least 16 bits.
The width of           [un]signed long   must be at least 32 bits.
The width of      [un]signed long long   must be at least 64 bits.
 That should be easy enough to remember now.
That table suggests that any program mixing 'short' and 'int' is suspect. If 'int' doesn't need to store values beyond 16 bits, then why not use 'short'?
'long' is another troublesome one. If the need is for 32-bit values, then it's surprisingly rare in source code.
In practice, most code now assumes that 'int' is 32 bits, and 'long' is inadvisedly used for 64 bits, since its actual width is typically:
                    long
Windows 32-bit     32 bits
Windows 64-bit     32 bits
Linux 32-bit       32 bits
Linux 64-bit       64 bits
My suggestion for writing code that is not going to run on 16-bit or lesser (or unusual) hardware is to assume:
   char        8 bits
   short      16 bits
   int        32 bits
   long long  64 bits
and to forget 'long'.

Date Sujet#  Auteur
22 Apr 26 o 

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal