strcmp with pointers not working in C

前端 未结 6 1312
情话喂你
情话喂你 2020-12-20 17:39

Why this code isn\'t working. Just trying to check if the user input is the same as a password

char *pass;

printf(\"Write the password: \");
scanf(\"%s\", p         


        
6条回答
  •  [愿得一人]
    2020-12-20 18:38

    You need to allocate the pass so the scanf will have a place to store the input. Otherwise you have memory corruption.

提交回复
热议问题