循环如何停止?
#include <stdio.h>#include <stdlib.h>
#define COUNT 10
int
main()
{
char *p =(char *)malloc( sizeof( char ) * ( COUNT + 1 ) );
unsigned int i = 0;
while( scanf( "%c", p + i ) == 1 )
{
i ++;
if( i > COUNT )
{
p = ( char * ) realloc( p, sizeof( char ) * (i + 1 ) );
if( p == NULL )
return NULL;
}
}
if( i < COUNT )
{
p = ( char * ) realloc( p, sizeof( char ) * ( i + 1 ) );
if( p == NULL )
return NULL;
}
*( p + i + 1 ) = NULL;
puts( p );
return 0;
}
怎么输入才能够使这个循环停止?????