Bonsoir,

Voilà, je dois faire un simple & logique entre deux signaux binaires générés aléatoirement. J'obtiens des adresses mémoire pour le résultat. Je constate que je n'ai toujours rien compris aux pointeurs, je suis triste -.-'

RESULTAT DE LA COMPILATION
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
 
 tableau[1]=1
 tableau[2]=1
 tableau[3]=0
 tableau[4]=0
 tableau[5]=1
 
 tableau[1]=0
 tableau[2]=0
 tableau[3]=0
 tableau[4]=0
 tableau[5]=0
 
 1 ET 0 = 3998128
 1 ET 0 = 3998128
 0 ET 0 = 1682005107
 0 ET 0 = 1768843629
 1 ET 0 = 1634890867
CODE

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
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#define T 5
 
int  *Remplissage        ( int *E, int *S                           );
void  Affichage_Init     ( int *E                                   );
int  *AND                ( int *E0, int *E1, int *S                 );
void  Affichage_Resultat (char *operation, int *E0, int *E1, int *S );
 
int main ()
{
 
    char And[3]="ET";
    char Or [3]="OU";
 
    int *a_init = (int*)malloc(T*sizeof(int));
    int *b_init = (int*)malloc(T*sizeof(int));
    int *a      = (int*)malloc(T*sizeof(int));
    int *b      = (int*)malloc(T*sizeof(int));
    int *s0     = (int*)malloc(T*sizeof(int));
    int *s1     = (int*)malloc(T*sizeof(int));
 
    Remplissage        ( a_init, a     );
    Remplissage        ( b_init, b     );
    Affichage_Init     ( a             );
    printf("\n");
    Affichage_Init     ( b             );
    printf("\n");
    AND                ( a, b, s0      );
    Affichage_Resultat ( And, a, b, s0 );
 
    getchar();
 
 
}
 
 
void Affichage_Init ( int *E )
{
    int i = 0;
    for ( i ; i<T ; i++ )
        {
            printf(" tableau[%d]=%d\n", (i+1), E[i]);
        }
}
 
void Affichage_Resultat ( char *operation, int *E0, int *E1, int *S )
{
    int i = 0;
    for ( i ; i<T ; i++ )
        {
            printf(" %d %s %d = %d \n", E0[i], operation, E1[i], S[i]);
        }
}
 
int *Remplissage( int *E, int *S )
{
    int i = 0;
    for ( i ; i<T ; i++ )
        {
            S[i]=rand()%2;
        }
 
    return S;
}
 
int *AND ( int *E0, int *E1, int *S )
{
    int i=0;
    for ( i ; i<T ; i++ )
        {
 
            if ( (E0[i]==0) && (E1[i]==0) )
               {
                            S[i]==0;
               }
 
            if ( (E0[i]==1) && (E1[i]==0) )
               {
                            S[i]==0;
               }
 
            if ( (E0[i]==0) && (E1[i]==1) )
               {
                            S[i]==0;
               }
 
            if ( (E0[i]==1) && (E1[i]==1) )
               {
                            S[i]==1;
               }
 
        }
 
        return S;
}
Merci d'avance.