Bonjour à tous,

J'ai un code qui fonctionne mais avec un pointeur qui se déinitialise?

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
/*  ttt-stripped <t.txt   */

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#define CINQPAGES 10240
#define LIGNES 100
#define Date: __DATE__

char strconv[10240];
char *toConsole ( char *p ) ;


char *toConsole ( char *p )
{
   CharToOemBuffA( p, strconv, 10240 );
   return strconv;
}

int main( void )
{
   char *pointeur = ( ( void * )0 );
   char *strst = ( ( void * )0 );
   char *reset = ( ( void * )0 );
   const char *cmp = "End_of_it.";
   int k = 1;
   int i = 0;
   int j = 0;
   char inligne[100] = {0};
   char intexte[3024] = {0};
   char substring[250] = {0};

   reset = &intexte[0];

   while ( ( ( void * )0 ) != fgets( inligne, sizeof inligne, ( &_iob[0] ) ) ) {
      strcat( intexte, inligne );
   }

   strcat( intexte, "\n" );

   strcat( intexte, cmp );
   strcat( intexte, "\n" );
   free( inligne );

   while ( 0 == strstr( substring , cmp ) ) {

      j = 0;

      substring[j++] = intexte[i];
      i++;

      while ( 1 != isupper( ( unsigned char )intexte[i] ) ) {
         substring[j++] = intexte[i];
         i++;
      }

      j--;

      while ( 0 == isgraph( ( unsigned char )substring[j] ) ) {
         j--;
      }
      j++;

      substring[j] = '\0';
      printf( "after %d--->%s<----\n\n", k++, substring );
      strst = &intexte[i];

      while ( ( ( void * )0 ) != ( pointeur = strstr( strst, substring ) ) ) {
         *pointeur++ = ' ';
         do {
            *pointeur++ = ' ';

         } while ( 1 != isupper( ( unsigned char )*pointeur ) );
         *( pointeur - 1 ) = ' ';
      }
   printf( "%s\n", toConsole( reset ) );  /*  OK  */
   }

   printf( "\n----------fin  -------------\n" );

   printf( "%s\n", toConsole( reset ) );  /*  ligne vide   */

   free( intexte );
   return 0;
}
Fichier.txt sur stdin:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
 
---------------------   <    t.txt  -------------------------------
 
C1ar, il sera ok hah bomb adil.	    Every shared library has a special.
C1ar, il sera ok hah bomb adil.
E3very shared library has a special.
---------------------   fin   t.txt  -------------------------------