Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "MyStruct.h"
- #include <stdio.h>
- void myStructConstructor(struct MyStruct *myStruct) {
- myStruct->setValue1 = setValue1;
- myStruct->setValue2 = setValue2;
- }
- void setValue1(struct MyStruct *myStruct, int myValue1) {
- myStruct->myValue1 = myValue1;
- }
- void setValue2(struct MyStruct *myStruct, char myValue2) {
- myStruct->myValue2 = myValue2;
- }
- int main(void) {
- MyStruct str;
- myStructConstructor(&str);
- str.setValue1(&str, 1);
- printf("%d\n", str.myValue1);
- str.setValue2(&str, 'a');
- printf("%c\n", str.myValue2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement