gcc warning 枚舉的輸入輸出

typedef enum {
A,B,C,
}DATA_SOURCE_ENUM;
 
int main(int argc ,char * argv[])
{
        DATA_SOURCE_ENUM source;
        printf("enter data source\n");
        scanf("%d",&source);
        printf("source=%d\n",source);
 
        return 0;
}

warning: format '%d' expects argument of type 'int *', but argument 1 has type 'enum DATA_SOURCE_ENUM *'


change to:

scanf("%d",(int*)&source);





(int *)

發佈了16 篇原創文章 · 獲贊 0 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章