Bonjour,

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
 
 
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <time.h>
 
#define TAILLE 100
 
typedef struct{
	char date[10];
	char intitule[10];
  	int priorite;
	int compteurtest;
	int etat;
}Test;
 
Test p[TAILLE];
 
int main() {
	FILE * pFile;
	pFile = fopen("export.txt", "r");
 
	int i;
	Test initialisation;
	for (i=0; i<100; i++) p[i] = initialisation;
	i = 0; 
 
 
 
	pFile = fopen("export.txt","r"); 
 
	while ((fscanf(pFile,"%s %d %s %d", p[i].intitule, &p[i].priorite,p[i].date, &p[i].etat)) != EOF )
    		i++;
 
    	tri_insertion();
	//test();
 
	fclose(pFile);
 
}
void tri_insertion()
{
	FILE * pFile = fopen("export.txt", "r");
	int nbLignes = compterLignes(pFile);
   	int i, j;
  	 for (i = 0; i < nbLignes; ++i) {
		char intitu[10];
		intitu = p[i].intitule;
      		int prio = p[i].priorite;
		//char * date = p[i].date;
		int etat = p[i].etat;
       		for (j = i; j > 0 && p[j-1].priorite > prio; j--){
			p[j].intitule = p[j-1].intitule;
           		p[j].priorite = p[j-1].priorite;
			p[j].etat = p[j-1].etat;
		}
		p[j].intitule = intitu;
       		p[j].priorite = prio;
		p[j].etat = etat;
		//p[j].date = p[i].date;
   	}
 
    	for(i = 1; i <= nbLignes; i++)
    	{
       	 printf("|%d|%s|%d|%s|%d\n", i, p[i-1].intitule, p[i-1].priorite,p[i-1].date,p[i-1].etat);
    	}
}
Voila mon code je souhaite faire un tri, je vais chercher les informations dans un fichier et je remplis un tableau de structure. ( le code fournit n'est pas complet)

Code compilation:

asdfinal.c:186:10: error: incompatible types when assigning to type ‘char[10]’ from type ‘char *’
intitu = p[i].intitule;
^
asdfinal.c:191:18: error: incompatible types when assigning to type ‘char[10]’ from type ‘char *’
p[j].intitule = p[j-1].intitule;
^
asdfinal.c:195:17: error: incompatible types when assigning to type ‘char[10]’ from type ‘char *’
p[j].intitule = intitu;