+ 5
Structures in C are non-primitive data structure which are used to club together various primitive or non-primitive variables together. If you are familiar with Object Oriented Paradigm or simply put, classes and objects. You can say that the structures are primitive classes. Because in C, structures can't have functions inside them so the advancement has put the classes in such a manner that they have now methods, inheritance, etc in more higher level languages like Java. You can also say structures in C laid down the foundation of classes and objects #include <stdio.h> struct person { int age; char *name; }; int main() { struct person first; struct person *ptr; first.age = 21; char *fullname = "full name"; first.name = fullname; ptr = &first; printf("age=%d, name=%s\n", first.age, ptr->name); } output => age =21 name= full name
21st Dec 2017, 4:44 PM
GAWEN STEASY
GAWEN STEASY - avatar