bswap

Table des matières
Retour à l'index

 

NOM

bswap_16, bswap_32, bswap_64 - inverser l'ordre des octets  

BIBLIOTHÈQUE

Bibliothèque C standard (libc, -lc)  

SYNOPSIS

#include <byteswap.h>

uint16_t bswap_16(uint16_t x);
uint32_t bswap_32(uint32_t x);
uint64_t bswap_64(uint64_t x);
 

DESCRIPTION

Ces fonctions renvoient une valeur dans laquelle l'ordre des octets de leurs arguments à 2, 4 ou 8 octets est inversé.  

VALEUR RENVOYÉE

Ces fonctions renvoient la valeur de leurs arguments avec l'ordre des octets inversé.  

ERREURS

Ces fonctions réussissent toujours.  

STANDARDS

GNU.  

EXEMPLES

Le programme ci-dessous inverse l'ordre des octets de l'entier à 8 octets spécifié comme argument de ligne de commande. La session shell suivante illustre l'utilisation de ce programme :

$ ./a.out 0x0123456789abcdef 0x123456789abcdef ==> 0xefcdab8967452301  

Source du programme

#include <byteswap.h> #include <inttypes.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) {
    uint64_t x;
    if (argc != 2) {
        fprintf(stderr, "Utilisation : %s <num>\n", argv[0]);
        exit(EXIT_FAILURE);
    }
    x = strtoull(argv[1], NULL, 0);
    printf("%#" PRIx64 " ==> %#" PRIx64 "\n", x, bswap_64(x));
    exit(EXIT_SUCCESS); }  

VOIR AUSSI

byteorder(3), endian(3)

 

TRADUCTION

La traduction française de cette page de manuel a été créée par Christophe Blaess <https://www.blaess.fr/christophe/>, Stéphan Rafin <stephan.rafin@laposte.net>, Thierry Vignaud <tvignaud@mandriva.com>, François Micaux, Alain Portal <aportal@univ-montp2.fr>, Jean-Philippe Guérard <fevrier@tigreraye.org>, Jean-Luc Coulon (f5ibh) <jean-luc.coulon@wanadoo.fr>, Julien Cristau <jcristau@debian.org>, Thomas Huriaux <thomas.huriaux@gmail.com>, Nicolas François <nicolas.francois@centraliens.net>, Florentin Duneau <fduneau@gmail.com>, Simon Paillard <simon.paillard@resel.enst-bretagne.fr>, Denis Barbier <barbier@debian.org>, David Prévot <david@tilapin.org> et Lucien Gentis <lucien.gentis@waika9.com>

Cette traduction est une documentation libre ; veuillez vous reporter à la GNU General Public License version 3 concernant les conditions de copie et de distribution. Il n'y a aucune RESPONSABILITÉ LÉGALE.

Si vous découvrez un bogue dans la traduction de cette page de manuel, veuillez envoyer un message à


 

Index

NOM
BIBLIOTHÈQUE
SYNOPSIS
DESCRIPTION
VALEUR RENVOYÉE
ERREURS
STANDARDS
EXEMPLES
Source du programme
VOIR AUSSI
TRADUCTION

This document was created by man2html, using the manual pages.
Time: 05:06:09 GMT, September 19, 2025