Structures in C/C++

by Shabbir on August 11, 2008

in C/C++

Structures are a group of data elements, and we can access them using the structures. The data elements can be from any types.

Sample of a structure

struct StructName
{
    int i;
    char c;
} obj1, obj2;

So, a structure is declared with the "struct" keyword, then comes its name. Then, in the braces we declare the data elements. After the braces we write the names (object) we will use for using that structure, that objects are global. We end with a semicolon.

Instead of the global object, we can create other objects wherever we want.
Here is an example of creating the object

struct StructName obj;

And then, using its data elements

obj.i=5;
obj.c='a';

We can create as many as we want objects from a structure.

Sharing is Caring...

Other Related Posts:

  1. Read/Write Registry Keys
  2. Write To File In C++
  3. Adding Items to ListView Control
  4. Write To File in C#
  5. ASP at a glance

{ 2 comments… read them below or add one }

style cuts for long hair October 7, 2009 at 9:28 am

i enjoyed reading this, keep up the good work. …,

Reply

style cuts for long hair October 7, 2009 at 2:28 pm

i enjoyed reading this, keep up the good work. …,

Reply

Leave a Comment

Spam protection by WP Captcha-Free

Previous post:

Next post:

    About the Author

  • author photo

    My Name is Shabbir Bhimani and I am developer by profession in the field of applications, web and database. Currently doing full time online marketing and like to share my experiences on how you can make money online @ CodeItWell.com. Read more ...


    See how you can get in touch with me.