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.

Share:
  • Digg
  • Facebook
  • StumbleUpon
  • Technorati
  • Twitter
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

Want More Tips on How to Make Money Online?
Enter your Name and Email below to subscribe and start 1 month free course now.

Name:
Email:
You would require to confirm your email address before we send you any updates. We respect your privacy as much as you do.
Powered by Aweber
blog comments powered by Disqus

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.