Home > Backend Development > C++ > In C language, compound literals

In C language, compound literals

PHPz
Release: 2023-09-11 10:09:03
forward
1373 people have browsed it

In C language, compound literals

In this section we will see what is the compound literals in C. The compound literals are introduced in C99 standard in C. Using this feature, it can create unnamed objects. In the following example we will see how to use compound literal to generate object without any name.

Example

#include<stdio.h>
struct point {
   int x;
   int y;
};
void display_point(struct point pt) {
   printf("(%d,%d)</p><p>", pt.x, pt.y);
}
main() {
   display_point((struct point) {10, 20});
}
Copy after login

输出

(10,20)
Copy after login

The above is the detailed content of In C language, compound literals. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template