Contenu d'une structure C
Bonjour,
j'ai une structure cend ou sont stockés differents résultats, j'aimerai lister le contenu de cette structure dans un fichier.
je fais une boucle pour afficher tous les élements de la structure, mais il m'affiche 4 valeurs: 0 52029128 0 0
Alors que le taille de la structure est 256.
vous pouvez m'aider svp.
Voila le code:
Code:
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
|
#define CONTROLSTACKSIZE 256
struct control *control[CONTROLSTACKSIZE];
struct control *cend[CONTROLSTACKSIZE];
int stackp = 0;
cp_evloop(char *string)
{
wordlist *wlist, *ww;
struct control *x;
char *i;
int nn;
FILE * pFile;
int c;
if (cend[stackp] && (cend[stackp]->co_type != CO_UNFILLED)) {
cend[stackp]->co_next = alloc(struct control);
ZERO(cend[stackp]->co_next, struct control);
cend[stackp]->co_next->co_prev = cend[stackp];
cend[stackp]->co_next->co_parent = cend[stackp]->co_parent;
cend[stackp] = cend[stackp]->co_next;
} else if (!cend[stackp]) {
control[stackp] = cend[stackp] = alloc(struct control);
ZERO(cend[stackp], struct control);
}
if (eq(wlist->wl_word, "if")) {
cend[stackp]->co_type = CO_IF;
cend[stackp]->co_cond = wl_copy(wlist->wl_next); /* va, wl_copy */
if (!cend[stackp]->co_cond) {
fprintf(stderr,
"Error: missing if condition.\n");
}
pFile = fopen ("file.txt","w+");
if (pFile!=NULL)
{
for (c=0;c< sizeof(cend[stackp]);c++)
fprintf(pFile,"%d\n", cend[c]);
fclose (pFile);
}
}
newblock; |
Merci