why the output is last string from user?

后端 未结 7 1916
北海茫月
北海茫月 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条回答
  •  旧时难觅i
    2020-12-22 11:19

    You are storing every string in the same place, overwriting the previous string each time. Don't do that. str is a buffer, and all of the pointers in the array arr are pointing at it.

提交回复
热议问题