Académique Documents
Professionnel Documents
Culture Documents
TP 3
TP 3
Classe :
GE1 S4
Exercice 1 :
#include <stdio.h>
#include <string.h>
int main()
char verbe[27];
char*pos;
int i;
do
fgets(verbe,27, stdin);
if (pos != NULL)
*pos = '\0';
}
while (strcmp(pos, "er"));
strcpy(pos, term[i]);
return 0;
Excution1 :
Probleme :
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef struct {
char nom[256];
char prenom[256];
int cin;
} Etudiant;
int i;
char*pos1,*pos2;
for(i=0;i<n;i++)
fflush(stdin);
fgets((tab+i)->nom,20,stdin);
pos1=strchr((tab+i)->nom,'\n');
if(pos1!=NULL)
*pos1='\0';
printf("Le prenom de l'etudiant est : ");
fflush(stdin);
fgets((tab+i)->prenom,20,stdin);
pos2=strchr((tab+i)->prenom,'\n');
if(pos2!=NULL)
*pos2='\0';
fflush(stdin);
scanf("%d",&(tab+i)->cin);
*test = 1;
return *test;
int i;
for(i=0;i<n;i++)
fclose(f);
int nombredelignes(char*nomdufichier)
char c;
if (c == '\n')
nblignes++;
fclose(f);
return nblignes;
int main()
int n;
Etudiant*tab;
scanf("%d", &n);
tab=(Etudiant*)malloc(n * sizeof(Etudiant));
if (test)
afficher(tab, n);
sauvegarder(tab, n);
free(tab);
return 0;
}
Excution :