Defining and using structures in C - Printable Version +- QP School (https://qomplainerzschool.lima-city.de) +-- Forum: Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=3) +--- Forum: C 18 Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=32) +--- Thread: Defining and using structures in C (/showthread.php?tid=5095) |
Defining and using structures in C - Qomplainerz - 07-25-2023 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; } |