본문 바로가기

Computer General/C++ development from the beginning

Structures

#include <iostream>
#include <cmath>
struct newperson
{
 //members(all of bits of information)
 //person's name
 char name[20];
 int age;
};
int main()
{
 using namespace std;
 //1. declaration of newperson
 newperson bucky =
 {
  "Bucky", 21
 };

 //then how can we use?
 cout<<bucky.age <<endl;
 newperson jack ={"jack bill", 45};
 cout<<jack.name<<"is "<<jack.age<<"years old"<<endl;
 system("pause");
 return 0;
}

'Computer General > C++ development from the beginning' 카테고리의 다른 글

File Input/Output  (0) 2014.12.16
Switch statement  (0) 2014.12.16
Logical OR operator  (0) 2014.12.16
The if Statement  (0) 2014.12.12
Address Operator & Pointer  (0) 2014.12.12