char * input = malloc(sizeof(char)); int end = 0; char x; while((x = getchar()) != '\n') { input[end] = x; input = realloc(input,sizeof(char) * (end + 3)); end++; } input[end] = 0;
使用这样的代码读取输入会导致输入超时,是为什么?