



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




struct mystruct { int a; char* b; } ; //note: could put st here instead struct mystruct st; char* pb = (char*)&st + offsetof(struct mystruct, b);
#include<stdio.h> typedef struct { int i; float PI; char A; } RECORD; int main() { RECORD ptr_one; ptr_one = (RECORD ) malloc (sizeof(RECORD)); (ptr_one).i = 10; (ptr_one).PI = 3.14; (ptr_one).A = 'a'; printf("First value: %d\n",(ptr_one).i); printf("Second value: %f\n", (ptr_one).PI); printf("Third value: %c\n", (ptr_one).A); free(ptr_one); return 0; }
struct rec *ptr_one; ptr_one =(struct rec *) malloc (sizeof(struct rec)); ptr_one->i = 10; ptr_one->PI = 3.14; ptr_one->A = 'a'; printf("First value: %d\n", ptr_one->i); printf("Second value: %f\n", ptr_one->PI); printf("Third value: %c\n", ptr_one->A);