ccplusplus.com
Learn C, C++ Concepts
Friday, February 10, 2012
structure example in c
/************************************************************************* * File : struct.cpp * Author : Saurabh Gupta * Desc : structure example in c * Source : http://www.ccplusplus.com/p/c_15.html * Created : 11:40 AM Friday, February 10, 2012 *************************************************************************/ #include
#include
using namespace std; /* * create a structure and add some elements */ struct ccplusplus { string strSiteName; string strOwner; int nAge; string strLocation; string strDateCreated; }; int main () { // create tge structure object ccplusplus info; info.strSiteName = "http://www.ccplusplus.com/"; info.strOwner = "Saurabh Gupta"; info.nAge = 24; info.strLocation="India"; info.strDateCreated = "19-Dec-2011"; // print the structure elements cout << info.strSiteName << endl; cout << "Owner = " << info.strOwner << endl; cout << "Age = " << info.nAge << endl; cout << "Location = " << info.strLocation << endl; cout << "Created = " << info.strDateCreated << endl; return 0; } /* * OUTPUT * [sgupta@rhel6x86 struct]$ c++ struct.cpp -o struct [sgupta@rhel6x86 struct]$ ./struct http://www.ccplusplus.com/ Owner = Saurabh Gupta Age = 24 Location = India Created = 19-Dec-2011 [sgupta@rhel6x86 struct]$ */
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment