Apres avoir cherché je décide de posté
le code coince sur la fonction initialiser
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
#include <stdio.h>
#include <stdlib.h>
 
struct Personnage
{
    char nom[100];
    char prenom[100];
    int age;
};
 
void copiechaine(char *joueurs, const char* info)
{
    int i=0;
    while(info[i] != '\0')
    {
        joueurs[i]=info[i];
        i++;
    }
    joueurs[i]='\0';
}
 
void initialiser(Personnage joueurs[]);
 
int main()
{
    struct Personnage joueurs[2];
    initialiser(joueurs);
 
    char benjamin[]="benjamin";
    char sophea[]="sophea";
 
    copiechaine(&joueurs[0].prenom, benjamin);
    copiechaine(&joueurs[1].prenom, sophea);
 
    int z=0;
    while(z < 2){
       printf("Le joueurs %d s'apelle %s \n", z,joueurs[z].prenom);
       z++;
    }
    return 0;
}
 
void initialiser(Personnage joueurs[]){
    int i=0,y=0;
    while(i<2)
    {
        while(y<101)
        {
            joueurs[i].nom[y]=0;
            joueurs[i].prenom[y]=0;
            y++;
        }
        y=0;
        joueurs[i].age=0;
        i++;
    }
 
}
Par avance je vous remercie !