IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C Discussion :

Probleme d'affichage de fichiers


Sujet :

C

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Étudiant
    Inscrit en
    Août 2006
    Messages
    44
    Détails du profil
    Informations personnelles :
    Localisation : Maroc

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Août 2006
    Messages : 44
    Par défaut Probleme d'affichage de fichiers
    Salut a tous,je travaille sur un projet qui fait appelle a 2 programme.(je programme avec borland C).
    Le premier programme est un programme simple de saisie,que j enregistre dans un fichier.
    Le deuxieme est plutot long et il fait apelle au 1er programme,pour afficher toutes les informations.

    Mon probleme c'est que quand j'utilise le deuxieme programme(le principal),ne m'affiche que la premier information que j ai fait rentrer!!c'est tout,le reste c'est comme si je n avais rien taper!!!

    Alors que quand je consulte le fichier,il est normalemement remplie!!!!

    voici un bout de code du programme principal qui vous expliquera mieux:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
     
    #include<stdio.h>
    #include<conio.h>
    #include <iostream.h>
    #include <stdlib.h>
    #include <string.h>
    #include <ctype.h>
    #include <io.h>
    #include <dos.h>
    void menuprincipal();
    void curseur(int);
    void cadre(int,int,int,int,int,int,int,int,int);
    int saisie1();
    int saisie2();
    int saisie3();
    void aff4(int,int,int);
    void init(int,int,int,int);
    void zorro(char []);
    void zorro1(char []);
    main()
    {
     
     
     
    char x;
     
       int n1,n2,n3;
     
      do
    	  {
       clrscr();
       menuprincipal();
       n1=saisie1();
       n2=saisie2();
       n3=saisie3();
       aff4(n1,n2,n3);
     
     
    switch(n1)
    {
    	case 0:
           {
     
    	char problem[35]={'A','F','R','I','Q','U','I','A','\0'};
    	zorro1(problem);
    	scanf("%c",&x);
     
    	break;
     
    	}
     
     
     
     
    	 case 1:
    	{
     
           char problem[35]={'A','t','l','a','s','\0'};
           zorro1(problem);
           scanf("%c",&x);
     
    	break;
     
    	}
     
     
     
          case 2:
          {
     
    	char problem[35]={'B','U','T','S','I','R','\0'};
    	zorro(problem);
    	scanf("%c",&x);
    	break;
          }
     
     
     
          case 3:
          {
     
    	 char problem[35]={"     CMH"};/*{'C','M','H','\0'};*/
    	 zorro(problem);
    	 scanf("%c",&x);
    	 break;
     
     
           }
     
           case 4:
           {
     
    	  char problem[35]={'D','I','M','A','G','A','Z','\0'};
    	  zorro(problem);
    	  scanf("%c",&x);
    	  break;
     
           }
     
     
           case 5:
     
           {
           char problem[35]={'D','O','U','N','I','A','\0'};
           zorro1(problem);
           scanf("%c",&x);
           break;
     
           }
     
           case 6:
     
           {
           char problem[35]={'D','R','A','G','O','N','\0'};
           zorro1(problem);
           scanf("%c",&x);
           break;
     
           }
     
           case 7:
     
           {
           char problem[35]={'F','l','e','u','r','\0'};
           zorro1(problem);
           scanf("%c",&x);
           break;
     
           }
     
           case 8:
     
           {
           char problem[35]={'N','A','D','I','\0'};
           zorro1(problem);
           scanf("%c",&x);
           break;
           }
     
     
           case 9:
     
           {
           char problem[35]={'N','A','T','I','O','N','A','L','\0'};
           zorro1(problem);
           scanf("%c",&x);
           break;
           }
     
     
    	case 10:
     
    	{
    	char problem[35]={'P','E','T','R','O','M','\0'};
    	zorro(problem);
    	scanf("%c",&x);
    	break;
    	}
     
    	case 11:
     
    	{
    	char problem[35]={'S','D','B','P','\0'};
    	zorro(problem);
    	scanf("%c",&x);
    	break;
    	}
     
     
    	case 12:
     
    	{
     
    	char problem[35]= {'S','H','E','L','L','\0'};
    	zorro(problem);
    	scanf("%c",&x);
    	break;
     
    	}
     
    	case 13:
     
    	{
     
    	char problem[35]={'S','O','M','A','P','\0'};
    	zorro(problem);
    	scanf("%c",&x);
    	break;
     
    	}
     
     
    	case 14:
     
    	{
     
    	char problem[35]={'T','I','S','S','I','R','\0'};
    	zorro1(problem);
    	scanf("%c",&x);
    	break;
     
    	}
     
    	case 15:
     
    	{
     
    	char problem[35]={'T','O','T','A','L','\0'};
    	zorro(problem);
    	scanf("%c",&x);
    	break;
     
    	}
     
    	case 16:
     
    	{
     
    	char problem[35]={'Z','I','Z','\0'};
    	zorro1(problem);
    	scanf("%c",&x);
    	break;
     
    	}
     
     
     
     
     
     
     
     
    }
    }while(toupper(x)=='R');
    getch();
    //*******************************************************
    void zorro1(char problem [])
    {
     
    	     FILE *fichier;
     
     
    		     flushall();
     
    	     char client[35];
    	     char gaz[35];
    	     char anne[35];
    	     char mois[35];
    	     char k;
    	     int a,b,c,d,e,f,g,h,i,j;
    	     char nomfich[6]={'n','a','d','o','r','\0'};
    	     gotoxy(6,4);printf("Centre:NADOR");
     
    			 fichier=fopen(nomfich,"r");
     
       do
           {
    fscanf(fichier,"%s",client);
    if (strcmp(problem,client)==0)
    {
    	fscanf(fichier,"%s",gaz);
     
    	 gotoxy(58,2);fscanf(fichier,"%s",anne);printf("     ");gotoxy(58,2);printf("%s",anne);
    	 gotoxy(13,2);fscanf(fichier,"%s",mois);printf("            ");gotoxy(13,2);printf("%s",mois);
    	 gotoxy(35,9);fscanf(fichier,"%d",&a);printf("   ");gotoxy(35,9);printf("%d",a);
    	 gotoxy(66,9);fscanf(fichier,"%d",&b);printf("   ");gotoxy(66,9);printf("%d",b);
    	 gotoxy(35,12);fscanf(fichier,"%d",&c);printf("   ");gotoxy(35,12);printf("%d",c);
    	 gotoxy(66,12);fscanf(fichier,"%d",&d);printf("   ");gotoxy(66,12);printf("%d",d);
    	 gotoxy(35,16);fscanf(fichier,"%d",&e);printf("   ");gotoxy(35,16);printf("%d",e);
    	 gotoxy(66,16);fscanf(fichier,"%d",&f);printf("   ");gotoxy(66,16);printf("%d",f);
    	 gotoxy(35,19);fscanf(fichier,"%d",&g);printf("   ");gotoxy(35,19);printf("%d",g);
    	 gotoxy(66,19);fscanf(fichier,"%d",&h);printf("   ");gotoxy(66,19);printf("%d",h);
    	 gotoxy(35,22);fscanf(fichier,"%d",&i);printf("   ");gotoxy(35,22);printf("%d",i);
    	 gotoxy(66,22);fscanf(fichier,"%d",&j);printf("   ");gotoxy(66,22);printf("%d",j);
     
    	 k=getch();
     
    }
     
     
    	}while((fgetc(fichier)!=EOF)&(k==13));
    	gotoxy(48,6);curseur(1);textcolor(27);cprintf("Retour menu/Sortir(R/S)?");
    	flushall();
     
     
     
     
    		fclose(fichier);
     
     
     }
     
     
     
     
     
    }

  2. #2
    Expert éminent
    Avatar de Emmanuel Delahaye
    Profil pro
    Retraité
    Inscrit en
    Décembre 2003
    Messages
    14 512
    Détails du profil
    Informations personnelles :
    Âge : 68
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Retraité

    Informations forums :
    Inscription : Décembre 2003
    Messages : 14 512
    Par défaut
    Citation Envoyé par mehdi.berra
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    #include <iostream.h>
    Pas du C (et du mauvais C++)...

  3. #3
    Membre averti
    Profil pro
    Étudiant
    Inscrit en
    Août 2006
    Messages
    44
    Détails du profil
    Informations personnelles :
    Localisation : Maroc

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Août 2006
    Messages : 44
    Par défaut si si
    c'est du C,puisque je ne sais programmer qu'en C

    Alors tu m'aides au lieu de critiquer????

  4. #4
    Expert éminent
    Avatar de Emmanuel Delahaye
    Profil pro
    Retraité
    Inscrit en
    Décembre 2003
    Messages
    14 512
    Détails du profil
    Informations personnelles :
    Âge : 68
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Retraité

    Informations forums :
    Inscription : Décembre 2003
    Messages : 14 512
    Par défaut
    Citation Envoyé par mehdi.berra
    c'est du C
    Non. Pas de <iostream.h> en C. Poste du code C, après on verra.

  5. #5
    Membre averti
    Inscrit en
    Septembre 2006
    Messages
    15
    Détails du profil
    Informations personnelles :
    Âge : 44

    Informations forums :
    Inscription : Septembre 2006
    Messages : 15
    Par défaut
    Je te conseille de réduire ton code au minimum pour mettre en évidence ce qui ne fonctionne pas et nous redonner le code.

  6. #6
    Membre averti
    Profil pro
    Étudiant
    Inscrit en
    Août 2006
    Messages
    44
    Détails du profil
    Informations personnelles :
    Localisation : Maroc

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Août 2006
    Messages : 44
    Par défaut code + petit
    voila un code plus petit ( j ai simplement enlever des switch) et j ai enlever iostream pour que qelqu'un qui se reconnaitra puisse jouir ouiiiiiiiiiiii qu il va dire

    bref plus serieusement aidez moi
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    #include<stdio.h>
    #include<conio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <ctype.h>
    #include <io.h>
    #include <dos.h>
    void menuprincipal();
    void curseur(int);
    void cadre(int,int,int,int,int,int,int,int,int);
    int saisie1();
    int saisie2();
    int saisie3();
    void aff4(int,int,int);
    void init(int,int,int,int);
    void zorro(char []);
    void zorro1(char []);
    main()
    {
     
     
     
    char x;
     
       int n1,n2,n3;
     
      do
    	  {
       clrscr();
       menuprincipal();
       n1=saisie1();
       n2=saisie2();
       n3=saisie3();
       aff4(n1,n2,n3);
     
     
    switch(n1)
    {
    	case 0:
           {
     
    	char problem[35]={'A','F','R','I','Q','U','I','A','\0'};
    	zorro1(problem);
    	scanf("%c",&x);
     
    	break;
     
    	}
     
     
     
     
    	 case 1:
    	{
     
           char problem[35]={'A','t','l','a','s','\0'};
           zorro1(problem);
           scanf("%c",&x);
     
    	break;
     
    	}
     
     
     
          case 2:
          {
     
    	char problem[35]={'B','U','T','S','I','R','\0'};
    	zorro(problem);
    	scanf("%c",&x);
    	break;
          }
     
    //**********************************************
    void zorro(char problem [])
    {
     
    	     FILE *fichier;
     
     
    	     char client[35];
    	     char gaz[35];
    	     char anne[35];
    	     char mois[35];
    	     char k;
    	     int a,b,c,d,e,f,g,h,i,j;
    	     char nomfich[6]={'n','a','d','o','r','\0'};
     
    	    gotoxy(6,4);printf("Centre:NADOR");
     
    			 fichier=fopen(nomfich,"r");
     
       do
           {
    fscanf(fichier,"%s",client);
    if (strcmp(problem,client)==0)
    {
     
    	 gotoxy(58,2);fscanf(fichier,"%s",anne);printf("     ");gotoxy(58,2);printf("%s",anne);
    	 gotoxy(13,2);fscanf(fichier,"%s",mois);printf("            ");gotoxy(13,2);printf("%s",mois);
    	 gotoxy(35,9);fscanf(fichier,"%d",&a);printf("   ");gotoxy(35,9);printf("%d",a);
    	 gotoxy(66,9);fscanf(fichier,"%d",&b);printf("   ");gotoxy(66,9);printf("%d",b);
    	 gotoxy(35,12);fscanf(fichier,"%d",&c);printf("   ");gotoxy(35,12);printf("%d",c);
    	 gotoxy(66,12);fscanf(fichier,"%d",&d);printf("   ");gotoxy(66,12);printf("%d",d);
    	 gotoxy(35,16);fscanf(fichier,"%d",&e);printf("   ");gotoxy(35,16);printf("%d",e);
    	 gotoxy(66,16);fscanf(fichier,"%d",&f);printf("   ");gotoxy(66,16);printf("%d",f);
    	 gotoxy(35,19);fscanf(fichier,"%d",&g);printf("   ");gotoxy(35,19);printf("%d",g);
    	 gotoxy(66,19);fscanf(fichier,"%d",&h);printf("   ");gotoxy(66,19);printf("%d",h);
    	 gotoxy(35,22);fscanf(fichier,"%d",&i);printf("   ");gotoxy(35,22);printf("%d",i);
    	 gotoxy(66,22);fscanf(fichier,"%d",&j);printf("   ");gotoxy(66,22);printf("%d",j);
    	 k=getch();
     
    }
     
     
    	}while((fgetc(fichier)!=EOF)&(k==13));
    	gotoxy(48,6);curseur(1);textcolor(27);cprintf("Retour menu/Sortir(R/S)?");
    	flushall();
     
     
     
    		fclose(fichier);
     
     
     
     
    	 }

  7. #7
    Membre averti
    Profil pro
    Étudiant
    Inscrit en
    Août 2006
    Messages
    44
    Détails du profil
    Informations personnelles :
    Localisation : Maroc

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Août 2006
    Messages : 44
    Par défaut pro
    le seul problem comme je l ai dit c'est qu il m affiche seulemeent la premeire information que j ai saisie c est tout

    mais sinon aucun problem a la compilation

  8. #8
    Membre averti
    Inscrit en
    Septembre 2006
    Messages
    15
    Détails du profil
    Informations personnelles :
    Âge : 44

    Informations forums :
    Inscription : Septembre 2006
    Messages : 15
    Par défaut
    Je te propose d'essayer :
    1. ouverture d'un fichier
    2. écritures dans ce fichier
    3. fermeture du fichier
    4. réouverture du fichier
    5. lectures et affichages du fichier
    6. Fermeture du fichier

    Ensuite, si tout fonctionne bien, remet ton code petit à petit pour trouver d'où vient le problème.

  9. #9
    Expert éminent
    Avatar de Emmanuel Delahaye
    Profil pro
    Retraité
    Inscrit en
    Décembre 2003
    Messages
    14 512
    Détails du profil
    Informations personnelles :
    Âge : 68
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Retraité

    Informations forums :
    Inscription : Décembre 2003
    Messages : 14 512
    Par défaut
    Citation Envoyé par mehdi.berra
    voila un code plus petit
    Ne compile pas,
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    Project   : Forums
    Compiler  : GNU GCC Compiler (called directly)
    Directory : C:\dev\forums\
    --------------------------------------------------------------------------------
    Switching to target: default
    Compiling: main.c
    main.c:19: warning: return type defaults to `int'
    main.c: In function `main':
    main.c:29: warning: implicit declaration of function `clrscr'
    main.c: In function `zorro':
    main.c:90: warning: implicit declaration of function `gotoxy'
    main.c:118: warning: implicit declaration of function `textcolor'
    main.c:118: warning: implicit declaration of function `cprintf'
    main.c:119: warning: implicit declaration of function `flushall'
    main.c:83: warning: unused variable `gaz'
    main.c: In function `main':
    main.c:128: error: syntax error at end of input
    Process terminated with status 1 (0 minutes, 0 seconds)
    1 errors, 7 warnings
    même avec <conio2.h> à la place de <conio.h> (MinGW)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
     
    Project   : Forums
    Compiler  : GNU GCC Compiler (called directly)
    Directory : C:\dev\forums\
    --------------------------------------------------------------------------------
    Switching to target: default
    Compiling: main.c
    main.c:19: warning: return type defaults to `int'
    main.c: In function `zorro':
    main.c:119: warning: implicit declaration of function `flushall'
    main.c:83: warning: unused variable `gaz'
    main.c: In function `main':
    main.c:128: error: syntax error at end of input
    Process terminated with status 1 (0 minutes, 0 seconds)
    1 errors, 3 warnings

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Débutant] un probleme d'affichage sur fichier txt
    Par tita88 dans le forum MATLAB
    Réponses: 12
    Dernier message: 30/04/2011, 04h40
  2. probleme pour l'affichage du Fichier
    Par mathiew dans le forum Débuter
    Réponses: 2
    Dernier message: 30/04/2009, 19h56
  3. probleme d'affichage en ligne d'un fichier .swf
    Par kamnouz dans le forum Intégration
    Réponses: 1
    Dernier message: 10/09/2008, 13h52
  4. Problème d'affichage nom de fichier
    Par melmouj dans le forum Shell et commandes GNU
    Réponses: 1
    Dernier message: 06/07/2006, 16h53
  5. Problème d'affichage fichier texte
    Par justind1989 dans le forum Langage
    Réponses: 5
    Dernier message: 06/04/2006, 19h21

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo