首页 > 其他 > 详细

structDemo1

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

 

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!