Exercice en c

Résolu
Bonjour, je veux de l'aide pour ouvrir ce exercice:fait un programme qui:
1.créature d'un fichier
2.ajout
3.modifier
4.aficher
5.supprimer
et merci.

2 réponses

  • Votes
  • Date
  • Date décroissante
  1. creation fichier

    #include <stdio.h>
    main()
    {
    char nomfich[21] ;
    int n ;
    FILE * sortie ;
    printf ("nom du fichier à créer : ") ;
    scanf ("%20s", nomfich) ;
    sortie = fopen (nomfich, "w") ;
    do { printf ("donnez un entier : ") ;
    scanf ("%d", &n) ;
    if (n) fwrite (&n, sizeof(int), 1, sortie) ;
    }
    while (n) ;
    fclose (sortie) ;
    }

    affichage ;

    #include <stdio.h>
    main()
    {
    char nomfich[21] ;
    int n ;
    FILE * entree ;
    printf ("nom du fichier à lister : ") ;
    scanf ("%20s", nomfich) ;
    entree = fopen (nomfich, "r") ;
    while ( fread (&n, sizeof(int), 1, entree), ! feof(entree) )
    printf ("\n%d", n) ;
    fclose (entree) ;
    }
    1. contrib seulement ! ;)