Advertisement
NaZaRa

[FR] C Struct v1.0

Dec 21st, 2012
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.01 KB | None | 0 0
  1. /*
  2.  ============================================================================
  3.  Name        : H59.c
  4.  Author      : Julian
  5.  Version     : 1.0
  6.  Copyright   : no-copyright (free code snippet)
  7.  Description : Struct 1.0
  8.  ============================================================================
  9.  */
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <string.h>
  13. /* #include <math.h> */ // Pas utile
  14. int main(void) {
  15.     struct test1 {
  16.         char N[120]; // Le nom du personnage
  17.         char S[50]; // Son sexe (H/F)
  18.         int A; // Son age
  19.     };
  20.     struct test1 p1; // Création de personnage n°1/1 de notre structure
  21.     printf("\nEntrez le nom de la premiere personne: "); scanf("%s",&p1.N);
  22.     printf("\nSon sexe: "); scanf("%s",&p1.S); printf("\nEt son age: "); scanf("%d",&p1.A);
  23.     printf("\nLa première personne s'appelle %s, est un(e) %s et a %d d'age.\n",p1.N,p1.S,p1.A);
  24.     halt();
  25.     return 0;
  26. }
  27. void halt(int haltvar) { // Fonction secondaire
  28.     printf("tap on any key then tap on 'enter' to continue... ");
  29.     scanf("%d",&haltvar);
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement