码迷,mamicode.com
首页 > 其他好文 > 详细

structDemo1

时间:2014-07-01 17:16:06      阅读:151      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   for   io   

 

structDemo1

 

# include <iostream.h>
# include <malloc.h>
enum EType{
    One = 1,Tow,Three 
};

struct S1{
    int id ;
    char name  [111];
    long version ;
};


int main(void){
    EType one = Tow;
    cout << "one = " << one << endl ;

    cout << "hello world !!  " << endl ;
    cout  << endl  << "hello world !!  << endl ";
    
    for (int i  (1) ; i <4 ;i++){
        EType type = (EType) i ;
        if(One == type )
            cout << " is One " << endl;
        if(Tow == type)
            cout << " is Tow " << endl;
        if(Three == type)
            cout << " is Three " << endl;
    }
 
    cout << "i = " << i <<endl;

    S1 s1 = {1,"s1",11};
    
    cout << " s1.id = " <<  s1.id << " , s1.name = " << s1.name << " , s1.version = " << s1.version  << endl;
    
    S1 * ps1 = &s1;
    cout << "ps1->id = " << ps1->id << endl;

    ps1 = (struct S1 *)malloc( sizeof(struct S1));
    ps1->id = 2;
 
    (*ps1).version  = 2;
    cout << " ps1->id = "<< ps1->id << " ,(*ps1).version = " <<(*ps1).version << endl;

    return 0 ;
}

 

 

 

 

structDemo1,布布扣,bubuko.com

structDemo1

标签:style   blog   color   os   for   io   

原文地址:http://www.cnblogs.com/mjorcen/p/3817981.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!