Advertisement
Guest User

Untitled

a guest
May 21st, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include "MyStruct.h"
  2. #include <stdio.h>
  3.  
  4. void myStructConstructor(struct MyStruct *myStruct) {
  5.  
  6. myStruct->setValue1 = setValue1;
  7. myStruct->setValue2 = setValue2;
  8. }
  9.  
  10. void setValue1(struct MyStruct *myStruct, int myValue1) {
  11. myStruct->myValue1 = myValue1;
  12. }
  13.  
  14. void setValue2(struct MyStruct *myStruct, char myValue2) {
  15. myStruct->myValue2 = myValue2;
  16. }
  17.  
  18. int main(void) {
  19. MyStruct str;
  20.  
  21. myStructConstructor(&str);
  22.  
  23. str.setValue1(&str, 1);
  24.  
  25. printf("%d\n", str.myValue1);
  26.  
  27. str.setValue2(&str, 'a');
  28.  
  29. printf("%c\n", str.myValue2);
  30.  
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement