如何打印枚举类型:%d

#include <stdio.h>

typedef enum SessionState {
        SESSION_OPENING,  /* Session scope is being created */
        SESSION_ONLINE,   /* Logged in */
        SESSION_ACTIVE,   /* Logged in and in the fg */
        SESSION_CLOSING,  /* Logged out, but scope is still there */
} SessionState;

SessionState session_get_state(int s) {
        /* always check closing first */
        if (s == 1)
                return SESSION_CLOSING;
        if (s == 2)
                return SESSION_OPENING;

        return SESSION_ONLINE;
}

void main(){
    SessionState A;
    SessionState B;
    int a = 2;
    int *p = &a;
    A=session_get_state(1);
    B=session_get_state(*p);
    printf("%d\n",A);
    printf("%d\n",B);

}
posted @ 2017-06-16 20:27  苏小北1024  阅读(3444)  评论(0编辑  收藏  举报