Other contributors have said "Importance of C structures in computer programing?" is the same question as "What are structures c programming?" If you believe that these are not asking the same thing and should be answered differently, click here

What are structures c programming?

Answer:
Presuming you mean:
"What are structures in C (programming)"

(Data) Structures are a simple way to organize information.
Example:

Suppose you want to make a program that does arithmetic operations on fractions.
Since each fraction can be represented by a nominator and a denominator for each fraction you have you need two integers (or other numeric variable type), the solution with no structs would be to create two arrays , one for the nominators and the other for the denominators:

int nominators[10];
int denominators[10];

The problem with this approach is that it is prone to programmer errors the relation between nominators and denominators is not enforced.

By using structs one could enforce the relation of a nominator with its denominator:

struct Fraction
{
int nominator;
int denominator;
};

This is a struct definition, it defines a new variable type that consists of two int variables
named nominator and denominator. So now you can write this:

struct Fraction fractions[10];

This makes it simpler for the programmer to handle the data.


Structs are declared as any other variable type:
struct Fraction fraction; //The keyword struct is necessary

In order to get a struct's inner variables (members is the usual term) you must use the '.'(full-stop) operator as such:

fraction.nominator = 0; //This will set the nominator member to 0

The initialization of a struct a bit awkward at first:

struct Fraction fraction = {1,2};

This will initialize the nominator member of the variable fraction to 1
and the denominator member to 2.

Hope this solves your query.
First answer by ID1581729728. Last edit by ID1581729728. Question popularity: 17 [recommend question].