07-25-2023, 11:43 AM
Structures are user-defined data types that allow you to group multiple variables of different data types under a single name.
struct Person {
char name[50];
int age;
float salary;
};
int main() {
struct Person p1;
strcpy(p1.name, "John");
p1.age = 30;
p1.salary = 50000.0;
printf("Name: %s, Age: %d, Salary: %.2f\n", p1.name, p1.age, p1.salary);
return 0;
}
struct Person {
char name[50];
int age;
float salary;
};
int main() {
struct Person p1;
strcpy(p1.name, "John");
p1.age = 30;
p1.salary = 50000.0;
printf("Name: %s, Age: %d, Salary: %.2f\n", p1.name, p1.age, p1.salary);
return 0;
}
Also follow me on Youtube for videos about video games:
https://www.youtube.com/channel/UCxfkGVU...2mQ/videos
https://www.youtube.com/channel/UCxfkGVU...2mQ/videos