FreePrograms

  CONTACT US   ABOUT US   PRIVACY  DISCLAIMER

C Language Tutorial with Free C Programs

FREE C PROGRAMS 

What is C C vs C++ vs Java Program Structure Data Types in C Basic Rules of C & C++
Functions in C If, Else Conditions Loops in C Switch Case Arrays
Pointers Structures in C Strings in C Command Line Arguments Type Casting
Linked Lists Recursion Binary Trees Inheritance Multiple Inheritance
Templates File I/O Object Oriented Programming Data Structures in C C interview Questions

Structures & Unions in C : - C Programming Tutorial

A structure is a collection of variables under a single name where variables can be of different types.

Example :

typedef struct

 {
         char line[64];
         int num;
         int age;

         char hobb[128];

 } person;

We can pass structures as arguments to functions.

We can also make structure within a structure.

struct date 

int day; 
int month; 
int year; 
}; 
struct person

int num; 
char name[12]; 
char address[20]; 
structure date def; 
structure date doa; 
}oldperson, newperson;

Unions in C

Unions like structure contain members whose individual data types can be different from one another.

union person

int age; 
float sal; 
char n; 

code;

© COPYRIGHT 2009 ALL RIGHTS RESERVED FREECPROGRAMS.COM