Modification en langage c

lepa86 Messages postés 1 Date d'inscription   Statut Membre Dernière intervention   -  
Emmanuel Delahaye Messages postés 107 Date d'inscription   Statut Membre Dernière intervention   -
BONJOUR
je veux un programme modulaire en langage c qui permet de faire une modification dans un fichier. C'est tres urgent car g fait un code qui recherche d'abord l'identifiant puis affiche ces donner et modifi ensuite
A voir également:

2 réponses

Emmanuel Delahaye Messages postés 107 Date d'inscription   Statut Membre Dernière intervention   7
 
> BONJOUR
> je veux

"J'aimerais", "je voudrais", ... On est pas tes esclaves ...

> un programme modulaire en langage c qui permet de faire une modification
> dans un fichier.

Sans plus de précisions, impossible de donner une réponse définitive. Il faut connaitre la structure des données et la manières dont elles sont codées dans le fichier.

D'une manière générale, pour modifier un fichier, on recopie celui-ci dans un autre en intercalant les modifications "à la volée". Il est en effet quasiment impossible de modifier directement un fichier. Ensuite, on utilise rename() et éventuellement remove() pour finaliser.


> C'est très urgent car g fait un code qui recherche d'abord l'identifiant puis
> affiche ces donner et modifie ensuite

Les problèmes d'urgence ne nous concernent pas. Nous sommes des bénévoles qui répondons quand nous pouvons, en plus de nos activités ... C'est à toi de mieux planifier ton temps ...

C is a sharp tool
0
paul
 
void modifier_etu(void)
{
char ident [7];
char nomfichier[20];
struct etudiant *p;
struct etudiant *suiv;
int trouve =1 ,i=1,t=0;
p=0;
printf("vous pouvez commencer la modification\n\n\n");
printf("\ndonner le nom du fichier:\t\t");
scanf("%s",&nomfichier);
printf("\ndonner l'identifiant de l'etudiant:\t\t");
scanf("%s",&ident);
trouve=recherche_etud(nomfichier,ident);
if(trouve==-1)
{
printf("\t\tl'etudiant n'existe pas");
}
else
{
printf("\n\t\tVoici ces informations actuelles\n\n\n");
affiche_etud(nomfichier,trouve);
printf("\t\t SAISIR LES NOUVELLES DONNES DE L'ETUDIANT\n\n");
while(trouve >i)
{
p=p->suiv;
i++;
}
if(p!=NULL)
{
while((p!=NULL)&&(t==0))
{
if(p->id==ident)
{
printf("donner un nom\n");
scanf("%s",&etu.nom);
printf("donner un prenom\n");
scanf("%s",&etu.prenom);
printf("donner un identifiant\n");
scanf("%s",&etu.id);
printf("donner l'adresse de l'etudiant\n");
scanf("%s",&etu.adresse);
t=1; }
p=p->suiv;
}
}
}
getch();

}
si je compile il ne signale pas d'erreur mais il ne modifie pas je veux de l'aide moi aussi c'est urgent.
-1
Emmanuel Delahaye Messages postés 107 Date d'inscription   Statut Membre Dernière intervention   7
 
Je ne suis pas sûr que ça aide beaucoup ...

-------------- Build: Debug in hello ---------------

Compiling: main.c
Linking console executable: bin\Debug\hello.exe
C:\dev\hello\main.c: In function 'modifier_etu':
C:\dev\hello\main.c:9: warning: implicit declaration of function 'printf'
C:\dev\hello\main.c:11: warning: implicit declaration of function 'scanf'
C:\dev\hello\main.c:11: warning: char format, different type arg (arg 2)
C:\dev\hello\main.c:13: warning: char format, different type arg (arg 2)
C:\dev\hello\main.c:14: warning: implicit declaration of function 'recherche_etud'
C:\dev\hello\main.c:22: warning: implicit declaration of function 'affiche_etud'
C:\dev\hello\main.c:26: error: dereferencing pointer to incomplete type
C:\dev\hello\main.c:29: error: 'NULL' undeclared (first use in this function)
C:\dev\hello\main.c:29: error: (Each undeclared identifier is reported only once
C:\dev\hello\main.c:29: error: for each function it appears in.)
C:\dev\hello\main.c:33: error: dereferencing pointer to incomplete type
C:\dev\hello\main.c:36: error: 'etu' undeclared (first use in this function)
C:\dev\hello\main.c:44: error: dereferencing pointer to incomplete type
C:\dev\hello\main.c:48: warning: implicit declaration of function 'getch'
C:\dev\hello\main.c:6: warning: unused variable 'suiv'
Process terminated with status 1 (0 minutes, 5 seconds)
7 errors, 8 warnings
 
0