How to realize a Union in C language
This article mainly introduces the relevant knowledge of "how to realize a consortium in C language". The editor shows you the operation process through an actual case, and the operation method is simple, fast and practical. I hope this article "how to implement a consortium in C language" can help you solve the problem.
1. Definition:
Union (int I, short s, char c) un; un.i = 3; printf ("I% d", un.i); printf ("length =% d\ n", sizeof (un); / / = = 4, there is the largest variable to determine
two。 It is equivalent to the List T type in java.
3. Data exchanging
Void swap (int * p, int * Q) {int temp = * p; * p = * Q; * Q = temp;}
4. Print address
Int I = 2; printf ("% # x", & I)
5. Pointer prints array values
Int arr [] = {1Pert 2je 3je 4}; int * p = & arr; prinft ("% d\ n", * (pendant 0)); prinft ("% d\ n", * (pendant 1)). That's all for "how to implement a consortium in C language". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.