السلام عليكم و رحمة الله و بركاته
السؤال هو كيفية استخدام Pointers to Structures ؟
الكود:
#include <stdio.h>
#include <stdlib.h>
typedef struct Coordonnees Coordonnees;
typedef struct personne personne;
struct Coordonnees
{
int x; // Abscisses
int y; // Ordonnées
};
struct personne
{
char *nom;
char *prenom ;
struct Coordonnees *p[2];
};
int main()
{
Coordonnees momo;
personne karim;
momo.x=5;
momo.y=10;
karim.p[0]=&momo;
printf("%d\n\n",*(karim.p[0]));
printf("%d",*((karim.p[0])+1));
return 0;
}فتخرج النتيجة على هذا النحو
5 2147307520
عوض أن تكون هكذا
5 10
لماذا لم أحصل على النتيجة بشكل صحيح ؟؟؟
دون استخدام هذه الطريقة ؟؟
karim.p[0]=&momo.x;
karim.p[1]=&momo.y;
printf("%d\n\n",*(karim.p[0]));
printf("%d\n\n",*(karim.p[1]));