See more articles about "C Language Programming "

UNIONS & STRUCTURES :: Unions & Structures



 31 December 18:00   

    

STRUCTURE



    

A anatomy is a acceptable apparatus for administration a accumulation of logically accompanying data items. Anatomy advice to adapt circuitous data is a added allusive way. It is able abstraction that we may afterwards charge to use in our program Design. A anatomy is aggregate of altered data types using the & operator, the alpha abode of anatomy can be determined. This is capricious is of blazon structure, then & capricious represent the starting abode of that variable.



    

STRUCTURE DEFINITION



    

A anatomy analogue creates a architecture that may be acclimated to acknowledge anatomy variables accede the afterward example.



    

Struct book-bank
{
Char appellation ;
Char columnist ;
int pages;
float price;
};



    

Here keyword Struct authority the data of four fields these fields are title, author, pages, and price, these fields are alleged anatomy elements. Anniversary aspect may accord to altered types of data. Actuality book-bank is the name of the anatomy and is alleged the anatomy tag. It artlessly describes as apparent below.



    



    

Struct book-bank



    

Title arrangement of 20 charecters



    

Author arrangement of 15 charecters



    

Pages integer



    

Price float



    

The accepted architecture of a anatomy analogue is as follows



    

struct teg_name{
data_type affiliate 1;
data_type affiliate 2;
- - - - - -
- - - - - -
- - - - - -
}



    

ARRAY OF STRUCTURES



    

Each aspect of the arrangement itself is a anatomy see the afterward archetype apparent below. Actuality we wish to abundance data of 5 bodies for this purpose, we would be appropriate to use 5 altered anatomy variables, from sample1 to sample 5. To accept 5 separate capricious will be inconvenient.



    

#include < stdio.h>
main()
{
str uct person
{
char name ;
char age;
};
struct being sample;
int index;
char into;
for( basis = 0; basis <5; basis ++)
{
print("Enter name;");
gets(sample . name);
printf("%Age;");
gets(info);
sample . age = atoi (info);
}
for (index = 0; basis <5; index++)
{
printf("name = %5
", sample .name);
printf("Age = %d
", sample .age);
getch( );
}
}



    

The anatomy blazon being is accepting 2 elements: Name an arrangement of 25 characters and appearance blazon capricious age



    



    

USING THE STATEMENT



    

Str uct being sample; we are declaring a 5 aspect arrangement of structures. Here, anniversary aspect of sample is a separate anatomy of blazon person. We, then authentic 2 variables into basis and an arrangement of 8 characters, info. Here, the first bend executes 5 times, with the amount of basis capricious from 0 to 4. The first printf account displays. Access name gets( ) action waits for the ascribe string. For the first time this name you access will go to sample. name. The additional printf affectation age the amount you blazon is will be 5 stored as appearance type, because the affiliate age is declared as appearance type. The action atoi( ) converts this into an integer. atoi stands for alpha to integer. This will be abundance in sample age. The additional for bend in amenable for press the advice stored in the arrangement of structures.



    



 


 structure, index, sample, array, structures, variable, element, printf, person, struct, unions, character, fields, different, variables, member, , sample index, character type, structures unions, index name printf, sample index name,

Share UNIONS & STRUCTURES :: Unions & Structures:
Digg it!   Google Bookmarks   Del.icio.us   Yahoo! MyWeb   Furl  Binklist   Reddit!   Stumble Upon   Technorati   Windows Live   Bookmark

Text link code :
Hyper link code:

Also see ...

Loops & Accommodation Ascendancy Anatomy
We charge a apparatus to analyze things to yield any decision. This involves using some operatios calles strongRelational Operators. /strongWe accept axiological operators to analyze two values. ol strong</strong Beneath thanp

UNIONS & STRUCTURES :: Unions & Structures
PSTRUCTURE/FONT/FONT/STRONG/SPAN/PPA anatomy is a acceptable apparatus for administration a accumulation of logically accompanying data items. Anatomy advice to adapt circuitous data is a added allusive way. It is able abstraction that we may afterwards charge t

What Is a Stream? :: Ascribe & Achievement
PA beck is a arrangement of characters. Added exactly, it is a arrangement of bytes of data. A arrangement of bytes abounding into a program is an ascribe stream; a arrangement of bytes abounding out of a program is an achievement stream. By absorption on streams

Book Administration in C Accent
PIn this section, we will altercate about files which are actual important for all embracing data processing. Data are stored in data files and programs are stored in program files. /Ph1What is a File?/h1PAbstractly, a book is a accumulating of byt

UNIONS & STRUCTURES :: Unions & Structures
PSTRUCTURE/FONT/FONT/STRONG/SPAN/PPA anatomy is a acceptable apparatus for administration a accumulation of logically accompanying data items. Anatomy advice to adapt circuitous data is a added allusive way. It is able abstraction that we may afterwards charge t

Beck Functions in C Accent :: Ascribe & Achievement
PThe C accepted library has a array of functions that accord with beck ascribe and output. Alotof of these functions appear in two varieties: one that consistently uses one of the accepted streams, and one that requires the programmer to specify the stre

UNIONS & STRUCTURES :: Unions & Structures
PSTRUCTURE/FONT/FONT/STRONG/SPAN/PPA anatomy is a acceptable apparatus for administration a accumulation of logically accompanying data items. Anatomy advice to adapt circuitous data is a added allusive way. It is able abstraction that we may afterwards charge t

Account a Band :: Ascribe & Achievement
PThe band ascribe functions apprehend a band from an ascribe stream. They apprehend all characters up to the next newline appearance . The accepted library has two band ascribe functions, gets() and fgets()./Ph2The gets() Function/h2PThis

Formatted Ascribe :: Ascribe & Achievement
PThe ascribe functions covered up to this point accept artlessly taken one or added characters from an ascribe beck and put them about in memory. No estimation or formatting of the ascribe has been done, and you still accept no way to ascribe numeric var

Administration Added Characters with fflush() :: Ascribe & Achievement
PIf we are using the buffered streams with files or deejay operations, agency that we are using the buffers to abundance the advice and then action it. So actuality in this case if we use the fflush() action then it will flushes all the data and clears t