Structure en C
Altaryan
-
miramaze Messages postés 1429 Date d'inscription Statut Contributeur Dernière intervention -
miramaze Messages postés 1429 Date d'inscription Statut Contributeur Dernière intervention -
Ou est la problème dans mon code svp?
Il m'affiche a la fin:
error: syntax error before '.' token (pour la dernière ligne) sous Code Blocks.
Il m'affiche a la fin:
error: syntax error before '.' token (pour la dernière ligne) sous Code Blocks.
typedef struct
{
int reference;
double prix;
}Produit;
#include <stdlib.h> #include <stdio.h> #include "test.h" Produit produit; produit.prix = 10;
2 réponses
-
Produit produit;
Ok si tu souhaites faire une variable globale, même si c'est mal.
Mais produit.prix=10 fera crier ton compilateur puisqu'il est en dehors d'une fonction. -
Exactement faut plutôt faire du genre
#include <stdlib.h> #include <stdio.h> #include "test.h" typedef struct { int reference; double prix; } Produit; int main() { Produit produit; produit.prix = 10; return 0; }