Un petit programme en c

elam007 Messages postés 10 Statut Membre -  
 JE NE SAIS RIEN -
Bonjour,
aidez moi svp à écrire un programme qui affiche le nombre d'octets occupés par les types : char,short,int,long,float,double,longdouble.
je sais que je dois utiliser (sizeof) mais comment svp aidez moi......et merci????
Configuration: Windows XP
Internet Explorer 7.0

2 réponses

  1. coco
     
    Bonjour,
    la syntaxe exact de sizeof est :

    int=sizeof(type)
    telle que type est: char,short,int,long,float,double,longdouble; donc cette fonction return un nombre entier.

    Exemple :
    int TAILLE;
    TAILLE=sizeof(char);

    la valeur de TAILLE serra égale a 1 car la char est codé sur un (1) octet.

    reste plus ca changer le type pour obtenir le nembre d'octet du type.
    0
  2. JE NE SAIS RIEN
     
    #include <stdio.h>
    #include <stdlib.h>
    int main()
    { printf("TAILLE D'UN CARACTERE:%d\n",sizeof(char));
    printf("TAILLE D'UN SHORT:%d\n",sizeof(short));
    printf("TAILLE D'UN INT:%d\n",sizeof(int));
    printf("TAILLE D'UN FLOAT:%d\n",sizeof(float));
    printf("TAILLE D'UN DOUBLE:%d\n",sizeof(double));
    return 0;
    }

    voila entre ce programme en "C" tu aura un jolie resulta
    0