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
18BCE2182 ASSESS_1 Q1-6
Ascii contrasena segura
C programming example implementing a function to set a specified bit in an int (from ECE 2534)
18BCE2182 ASSESS_1 Q1-9
simple insertion sort
Sorting Character array using Qsort
18BCE2182 LAB FAT-2-A-ii
Binary to Integer (C)
garbage
B_141125_Repetidos