Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
FunPointUnion
//gcc 7.4.0 //FunPointUnion: example of union and function pointer //this code is created by Rezaul Hoque on March 31,2022;contact: jewelmrh@yahoo.com,Dhaka, Bangladesh //note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; #include <stdio.h> #include <string.h> union on{ int wage; }; struct emp{ char name[20]; int hour; union on u; }e; struct emp input(); void display(struct emp); struct emp input(){ struct emp t; strcpy(t.name,"www hhh"); t.hour=10; t.u.wage=200; return t; } void display(struct emp em){ printf("name: %s\n",em.name); printf("hours worked: %d\n",em.hour); printf("wage/hour: %d\n",em.u.wage); } int main(void) { struct emp m; struct emp (*p)(); p=input; m=(*p)(); display(m); return 0; }
run
|
edit
|
history
|
help
0
1
la profe
Mem alloc test
test
Lab 5 HW Spring 2017 v0.5
HW2A
18BCE2182 ASSESS_1 Q1-8
arrows
Instruction order in C/C++
EXercice