format '%s' expects argument of type 'char *'

后端 未结 7 517
野趣味
野趣味 2021-01-11 10:32
#include 
int main(void)
{
    int i,j,k;
    char st;
    printf(\"enter string\\n\");
    scanf(\"%s\", st);         


        
7条回答
  •  粉色の甜心
    2021-01-11 11:09

    scanf needs a pointer to char* to indicate you are scanning a string.

    You are supplying a character that's allocated on the stack.

    You either want to use a getchar() or make st a char array.

提交回复
热议问题