Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

i want to know about structure function in c programming

Computer Science
See more answers at
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly


Get your free account and access expert answers to this and thousands of other questions

it's used to define ur own data it's a boz or collection of different datatypes.....
i did not had a chance to study it ...... but i had some tutorial videos that they can help u... maybe u can give me ur email i will send them...

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

The struct keyword tells the compiler to bundle together a bunch of different data into one object, and as A.Avinash_Goutham mentioned, it's mainly used to define new types. For example, let's say one needs to program a singly-linked list in C. By default, C doesn't have any primitives to provide linked lists (in constrast to languages like Lisp), nor does C's standard library (in contrast to languages like C++ or Java that provide a bunch of general collection types). With C structs, you can implement singly-linked lists yourself :) One can start by defining the individual nodes of the singly-linked list. Without getting too much into the syntax details to accomplish this in C: struct node /* Node for singly-linked lists. */ { int datum; struct node *next; }; In the above struct definition you have a `node' object that contains two fields: a field to put data (of type int) in and another field that contains a `next' pointer to a node object. Might want to go further and specify lists themselves: struct list /* Singly-linked list. */ { struct node *head; struct node *tail; size_t len; }; You can define functions to allocate or initialize those structs for you: struct node *new_node(int datum, struct node *next) { struct node *node = malloc(sizeof(*node)); if (node != NULL) { node->datum = datum; node->next = next; } return node; } void free_node(struct node *node) { free(node); } You can also define functions to perform operations on your structs: void append_node(struct list *list, struct node *node) /** Add a node to the end of a singly-linked list. Probably better to define insert and delete instead but I'm just making an example :D */ { list->tail->next = node; } //Now you can do this: struct list *new_list(size_t len, int init) /** Initialize a singly-linked list with `len' nodes, each initialized to `init', and return a pointer to the list. */ { struct list *list = malloc(sizeof(*list)); if (list != NULL) { if (len == 0) { list->head = NULL; list->tail = NULL; } else { int i; list->head = new_node(init,NULL); list->tail = list->head; for (i = 1; i < len; ++i) { append_node(list, new_node(init, NULL)); } } list->len = len; } return list; } Things just go downhill after this point. :D As you can see, C structs help us define our own data structures. Though C structs aren't as powerful as the Classes and Objects you see in other languages (by comparison, C structs are just dumb data structures with no embedded logic), they get the job of grouping together variables related to particular objects quite well. Imagine implementing a linked list in C (or any data structure apart from array and list) without the use of structs!
looks pretty much like a c++ struct struct structname { type datatypename; //.. //etc.. as many other data members as you like can be of an type, even classes }; //DO NOT forget the semicolon defining a struct in your program// NOTE: must declare the struct before you use it strucname struct_instance; //assigning values struct_instance.datatypename=//whatever appropriate value, don't try to assign a string to an int... //getting values out x= struct_instance.datatype also note struct stores values in the order they are declared... so you can assign a pointer to a struct and read off values as any type by using a void pointer and then converting it to t type pointer...

Not the answer you are looking for?

Search for more explanations.

Ask your own question