Les fichier en c
hobaspirt
-
fiddy Messages postés 11069 Date d'inscription Statut Contributeur Dernière intervention -
fiddy Messages postés 11069 Date d'inscription Statut Contributeur Dernière intervention -
Bonjour,
jé un probléme o niveau des fichier lorsque je ferme le fichier il m'affich une erreur mais apres execution
alors jé besoin dela fonction ki copie directement de lecran a un fichier
jé un probléme o niveau des fichier lorsque je ferme le fichier il m'affich une erreur mais apres execution
alors jé besoin dela fonction ki copie directement de lecran a un fichier
A voir également:
- Les fichier en c
- Fichier bin - Guide
- Fichier epub - Guide
- Fichier rar - Guide
- Comment réduire la taille d'un fichier - Guide
- Fichier .dat - Guide
5 réponses
Salut,
nom_du_programme > nom_fichier_sortie.txt
Ceci va te rediriger la sortie du flux de ton programme dans un fichier texte.
nom_du_programme > nom_fichier_sortie.txt
Ceci va te rediriger la sortie du flux de ton programme dans un fichier texte.
Bonjour,
nn le probléme ke ca marche pour certain probléme mais je sais po pkoi pour ce dernier la premier execution c bien fait
mais apres il affiche des erreur et le fichier exe ve po se suprimé
nn le probléme ke ca marche pour certain probléme mais je sais po pkoi pour ce dernier la premier execution c bien fait
mais apres il affiche des erreur et le fichier exe ve po se suprimé
Bonjour,
voila
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<math.h>
float fct(float x, float y)
{
return y*cos(x);
}
/* allocation */
float *fvect(int n)
{
float *x;
x=(float*)malloc(n*sizeof(float));
if( x==NULL)
{
printf("\n Pb d'allocation de memoire");
getch();
exit(1);
}
return x;
}
void lire(float *a,float *b,float *ci, int *n)
{
printf("donner a:");
scanf("%f",a);
printf("donner b:");
scanf("%f",b);
printf("donner ci:");
scanf("%f",ci);
printf("donner n:");
scanf("%d",n);
}
void AB4(float a , float b , int n , float ci , float *x , float *y)
{
int i;
float h,k0,k1,k2,k3;
h = (b-a)/n;
x[0] = a;
for(i=1;i<4;i++)
x[i]=x[i-1]+h;
y[0] = ci;
y[1] = exp(sin(x[1]));
y[2] = exp(sin(x[2]));
y[3] = exp(sin(x[3]));
x[4]=a+4*h;
for(i=4;i<n;i++)
{
y[i+1]=y[i]+(h/24)*((55*fct(x[i],y[i]))- (59*fct(x[i-1],y[i-1]))+(37*fct(x[i-2],y[i-2]))- (9*fct(x[i-3],y[i-3])));
x[i+1]=x[i]+h;
}
}
main()
{
FILE *out;
float a,b,h,ci,*xa,*ya;
int i,n;
out=fopen("fct5.txt","at");
lire (&a,&b,&ci,&n);
xa = fvect(n);
ya = fvect(n);
AB4(a,b,n,ci,xa,ya);
fprintf(out," Adams-Bashforth\t\tExacte\n\n");
for(i=1; i<n; i++)
{
fprintf(out,"\tAB(%.2f)=%f\t%f\n",xa[i],ya[i],exp(sin(xa[i])));
}
fclose(out); /* voila c ici ou je trouve des peobléme */
getch();
}
méme pour vider x et y il m'affiche des erreur
voila
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<math.h>
float fct(float x, float y)
{
return y*cos(x);
}
/* allocation */
float *fvect(int n)
{
float *x;
x=(float*)malloc(n*sizeof(float));
if( x==NULL)
{
printf("\n Pb d'allocation de memoire");
getch();
exit(1);
}
return x;
}
void lire(float *a,float *b,float *ci, int *n)
{
printf("donner a:");
scanf("%f",a);
printf("donner b:");
scanf("%f",b);
printf("donner ci:");
scanf("%f",ci);
printf("donner n:");
scanf("%d",n);
}
void AB4(float a , float b , int n , float ci , float *x , float *y)
{
int i;
float h,k0,k1,k2,k3;
h = (b-a)/n;
x[0] = a;
for(i=1;i<4;i++)
x[i]=x[i-1]+h;
y[0] = ci;
y[1] = exp(sin(x[1]));
y[2] = exp(sin(x[2]));
y[3] = exp(sin(x[3]));
x[4]=a+4*h;
for(i=4;i<n;i++)
{
y[i+1]=y[i]+(h/24)*((55*fct(x[i],y[i]))- (59*fct(x[i-1],y[i-1]))+(37*fct(x[i-2],y[i-2]))- (9*fct(x[i-3],y[i-3])));
x[i+1]=x[i]+h;
}
}
main()
{
FILE *out;
float a,b,h,ci,*xa,*ya;
int i,n;
out=fopen("fct5.txt","at");
lire (&a,&b,&ci,&n);
xa = fvect(n);
ya = fvect(n);
AB4(a,b,n,ci,xa,ya);
fprintf(out," Adams-Bashforth\t\tExacte\n\n");
for(i=1; i<n; i++)
{
fprintf(out,"\tAB(%.2f)=%f\t%f\n",xa[i],ya[i],exp(sin(xa[i])));
}
fclose(out); /* voila c ici ou je trouve des peobléme */
getch();
}
méme pour vider x et y il m'affiche des erreur
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question