Les fichier en c

hobaspirt -  
fiddy Messages postés 441 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
Configuration: Windows XP
Internet Explorer 6.0

5 réponses

  1. fiddy Messages postés 441 Date d'inscription   Statut Contributeur Dernière intervention   1 847
     
    Salut,

    nom_du_programme > nom_fichier_sortie.txt

    Ceci va te rediriger la sortie du flux de ton programme dans un fichier texte.
    0
  2. hobaspirt
     
    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é
    0
  3. fiddy Messages postés 441 Date d'inscription   Statut Contributeur Dernière intervention   1 847
     
    Pourrais-tu donner un exemple concret. Un copier coller du problème que tu as encouru.

    0
  4. hobaspirt
     
    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
    0
  5. Vous n’avez pas trouvé la réponse que vous recherchez ?

    Posez votre question
  6. fiddy Messages postés 441 Date d'inscription   Statut Contributeur Dernière intervention   1 847
     
    Salut,

    En fait, ce que j'attendais, c'était les messages d'erreurs.
    Lance ton programme à la console, fais apparaitre les erreurs, et tu copies colles le tout y compris le lancement du programme.

    Merci d'avance
    0