Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize a Union in C language

Shulou Source: shulou.com Published: 2022-06-01 01:48:20 10月31日 Update

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.

Tags: Consortium language federation knowledge industry different practical maximum content variable address practicality actual pointer data array article method more case Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Shulou Technology NVidia MySQL Huawei