Si vous pouvez m'aider pour un programme de C

vall -  
 vall -
Bonjour,je dois faire un programme en C mais j'ai un peu de difficultes.Et si vous pouvez m'aider je vous serais tres reconnaissante
Ecrire un programme qui crée un fichier texte INFO.TXT qui est la copie exacte (enregistrement par enregistrement) du fichier INFORM.TXT (les éléments sont chaînes de caractères).
• Ajouter un nouvel enregistrement (entré au clavier) à la fin de INFO.TXT.
• Supprimer dans INFO.TXT tous les enregistrements dont le premier mot est égal à un mot donné.
• Déplacer dans un fichier nouveau NOUV.TXT toutes les lignes qui ont plus de trois mots.

6 réponses

Qwerti Messages postés 166 Date d'inscription   Statut Membre Dernière intervention   85
 
Salut vall,

Quelles sont tes connaisssance en C ? Car ca a l'air assez basic ce que tu demandes la...

a+
-Qwerti.
0
vall
 
Je dois faire cette programme en C
0
Qwerti Messages postés 166 Date d'inscription   Statut Membre Dernière intervention   85
 
Et bien vas-y et poste-nous le résultat quand tu auras fini !!! On est impatients de voir ca...

a+ et bon courage,
-Qwerti.
0
mype Messages postés 2435 Date d'inscription   Statut Membre Dernière intervention   437
 
qwerty a raison on va pas te faire tout l'exo car tu n'apprendras rien de cette façon
poste deja ce que tu as essayé de faire et on corrigera tes erreurs...
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
vall
 
voyez qu'est ce que j'ai fais,mais je dois faire encore cette fonction :• Déplacer dans un fichier nouveau NOUV.TXT toutes les lignes qui ont plus de trois mots. Si vous pouvez m'aider



#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 90
char filename[N],filename1[N];
void menu();
void enter();
void display();
void move();
void filecopy(FILE* txt1, FILE* txt2);
void nouvel_enregistrement(FILE* txt1);
void main()
{
menu();
}
void menu()
{ FILE* txt1;
int choise;
printf("MENU: \n");
printf(" 1. Record !\n");
printf(" 2. Show!\n");
printf(" 3. Move\n");
printf(" 4. Ajouter un nouvel enregistrement a la fin de INFO.TXT\n");
printf(" 5. Exit\n");
do{
printf("Enter: ");
scanf("%d",&choise);
}while(choise<1 || choise>5);
switch(choise)
{
case 1:
{
enter();
break;
}
case 2:
{
display();
break;
}
case 3:
{
move();
break;
}
case 4:
{
nouvel_enregistrement(txt1);
break;
}
case 5:
exit(1);
}
}
void enter()
{
FILE* txt1,*txt2;
char s[N];

printf("Filename: ");
scanf("%s",&filename);

printf("Filename: ");
scanf("%s",&filename1);
txt1=fopen(filename,"w");
if(txt1==NULL)
{
printf("Error! The file can't be open!");
exit(1);
}
txt2=fopen(filename1,"w");
if(txt1==NULL)
{
printf("Error! The file can't be open!");
exit(1);
}
while(1)
{
fflush(stdin);
printf("Enter string: ");
gets(s);
if(!strcmp(s,"exit"))
break;
fflush(stdin);
fprintf(txt1,"%s",s);
fputc('\n',txt1);
}
fclose(txt1);
fclose(txt2);
menu();
}
void filecopy(FILE* txt1,FILE* txt2)
{
char s[N];
txt1=fopen(filename,"r");
if(txt1==NULL)
{
printf("Error! The file can't be open!");
exit(1);
}
txt2=fopen(filename1,"w");
if(txt1==NULL)
{
printf("Error! The file can't be open!");
exit(1);
}
while((fscanf(txt1,"%s",s))!=EOF)
{
fprintf(txt2,"%s",s);
fflush(stdin);
}
fclose(txt1);
fclose(txt2);
menu();
}
void display()
{
char s[N];
FILE* txt1;
txt1=fopen(filename,"r");
if(txt1==NULL)
{
printf("Error! The file can't be open!");
exit(1);
}
while((fscanf(txt1,"%s",s))!=EOF)
puts(s);
fclose(txt1);
menu();
}
void move()
{
FILE* txt1, *help;
int flag=0;
int i;
char s[N];
txt1=fopen(filename,"r");
if(txt1==NULL)
{
printf("Error! The file can't be open!");
exit(1);
}
strcpy(filename1,"help.txt");
help=fopen(filename1,"w");
if(help==NULL)
{
printf("Error! The file can't be open!");
exit(1);
}
while((fscanf(txt1,"%s",s))!=EOF)
{
flag=1; //true
if((strlen(s)>=3))
{
fprintf(help,"%s",s);
puts(s);
}
}
if(!flag)
printf("The file is empty!\n");
strcpy(filename1,filename);
strcpy(filename,"help.txt");
filecopy(help,txt1);
fclose(txt1);
fclose(help);
}
void nouvel_enregistrement(FILE* txt1)
{
int place;
char s[N];
txt1=fopen(filename,"a+");
if(txt1==NULL)
{
printf("Error! The file can't be open!");
exit(1);
}
printf("Enter string: ");
scanf("%s",&s);
fflush(stdin);
place=ftell(txt1);
fseek(txt1,place,0);
fprintf(txt1,"%s",s);
fclose(txt1);
txt1=fopen(filename,"r");
if(txt1==NULL)
{
printf("Error! The file can't be open!");
exit(1);
}
printf("Voyez le nouvel enregistrement dans INFO.TXT\n");
while((fscanf(txt1,"%s",s))==1) {
puts(s);
}
fclose(txt1);
menu();
}
0
vall
 
est ce que vous pouver m'aider???
0