why the output is last string from user?

后端 未结 7 1880
北海茫月
北海茫月 2020-12-22 10:53
#include
#include
int main()
{
    int in,i,j;
    char *arr[100],str[14];
    scanf(\"%d\",&in);
    i=0;
    while(i

        
相关标签:
7条回答
  • 2020-12-22 11:34

    Try something like this in your loop.

    while(i<in)
    {
        scanf("%s",str);
        arr[i]=malloc(sizeof(char) * strlen(str));
        strcpy(arr[i],str);
      //  printf("%s\n",arr[i]);
        i++;
    
    }
    
    0 讨论(0)
提交回复
热议问题