|
From: Elizabeth B. <sog...@ya...> - 2002-10-25 15:31:21
|
chr...@cr... writes:
> Who help me ? If i compiled this project with devcpp 4.9.6, i have messages
> :
It does not appear to me that you included the definition of the Forme
struct in struc.c. This is how most would arrange your code:
"struc.h":
~~~~~~~~~~
#ifndef STRUC_H
#define STRUC_H
struct Forme
{
int type;
int couleur;
};
void
change_structure(struct Forme *Forme);
#endif
"struc.c":
~~~~~~~~~~
#include "struc.h"
void
change_structure(struct Forme *Forme)
{
(*Forme).type=0;
(*Forme).couleur=1;
}
"main.c":
~~~~~~~~~
#include <stdio.h>
#include "struc.h"
int
main(int argc, char *argv[])
{
struct Forme cercle;
change_structure(&cercle);
printf("cercle.type %d\n", cercle.type);
printf("cercle.couleur %d\n", cercle.couleur);
system("PAUSE");
return 0;
}
There are various ways to do it, of course, but both struc.c and
main.c need the definiton of struct Forme, so it is better to define
it in one place (struc.h) and have both files reference (#include) it.
Elizabeth
|