int
readLine(
char
buffer[])
{
char character;
int i=0;
do
{
character =getchar();
buffer[i]=character;
++i;
}while (character!='\n');
buffer[i-1]='\0';
return i-1;
}
{
char character;
int i=0;
do
{
character =getchar();
buffer[i]=character;
++i;
}while (character!='\n');
buffer[i-1]='\0';
return i-1;
}
int
main()
{
char line[1000];
int length;
length=readLine(line);
}
就是用getchar()来读取一行就行了,自定义一下函数,方便重用.
{
char line[1000];
int length;
length=readLine(line);
}