Switch statement using string on an array

前端 未结 8 1421
礼貌的吻别
礼貌的吻别 2021-01-13 06:28
#include

int main(){

    char name[20];

    printf(\"enter a name \");
    scanf(\"%s\",name);
    switch(name[20]){
        case \"kevin\" : 
             


        
8条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-13 07:17

    since the name is declared as a char type ,it would be better if you use "%c" instead of using "%s" inside the scanf() method.

提交回复
热议问题