1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| #include <stdio.h>
#include <stdlib.h>
int main ()
{
int i = 0;
char Noms[][25];
puts("\nPour terminer, tapez EOF (Ctrl + Z) ");
Noms = (char *) malloc(1 * sizeof(char));
do
{
printf("\nVeuillez entrer un nom svp: ");
gets(Noms[i]);
i++;
Noms = (char *) realloc (Noms, i * sizeof (char));
printf("\nVeuillez entrer un nom svp: ");
}while(!feof(stdin));
printf ("Liste de noms saisis: ");
for (int n = 0; n<i; n++)
{
printf ("%s ",Noms[n]);
}
free (Noms);
getchar();
return 0;
} |
Partager