Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdbool.h>
- typedef struct
- {
- unsigned char x;
- int y;
- bool z;
- } type_a;
- typedef struct
- {
- int a;
- int b;
- } type_b;
- void transmit_struct(int numb, unsigned int *data_struct);
- int main()
- {
- type_a data_a = {0};
- type_b data_b = {0};
- data_a.x = 12;
- data_a.y = 100;
- data_a.z = true;
- data_b.a = 150;
- data_b.b = 2000;
- system("chcp 1251");
- system("cls");
- transmit_struct(0, &data_a);
- transmit_struct(1, &data_b);
- system("pause");
- return 0;
- }
- void transmit_struct(int numb, unsigned int *data_struct)
- {
- switch (numb)
- {
- case 0:
- {
- printf("Значение x: %d.\n", ((type_a *)(data_struct))->x);
- printf("Значение y: %d.\n", ((type_a *)(data_struct))->y);
- printf("Значение z: %d.\n", ((type_a *)(data_struct))->z);
- break;
- }
- case 1:
- {
- printf("Значение a: %d.\n", ((type_b *)(data_struct))->a);
- printf("Значение b: %d.\n", ((type_b *)(data_struct))->b);
- break;
- }
- default:
- {
- printf("Oooops\n.");
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement