Re: HELP!! Two questions from <<the c programming language>>
- From: Ben Bacarisse <ben.usenet@xxxxxxxxx>
- Date: Thu, 31 May 2007 14:04:55 +0100
Tak <kakataka@xxxxxxxxx> writes:
<bad algorithm snipped>Algorithm trim_space
My program of exercise 1-9
#include <stdio.h>
int main()
{
int flag=1;
int c;
while ((c = getchar()) != EOF)
{
if (c == ' ')
{
flag = 0;
}
else if (flag == 0)
{
printf(" ");
putchar(c);
flag = 1;
}
else
putchar(c);
}
}
It seems run OK,without error or warning in Vc++6.0.
Does it still contain any problems?
Yes. What happens when the input ends with one or more spaces?
--
Ben.
.
- Follow-Ups:
- Re: HELP!! Two questions from <<the c programming language>>
- From: Guru Jois
- Re: HELP!! Two questions from <<the c programming language>>
- References:
- HELP!! Two questions from <<the c programming language>>
- From: Tak
- Re: HELP!! Two questions from <<the c programming language>>
- From: Ian Collins
- Re: HELP!! Two questions from <<the c programming language>>
- From: Tak
- Re: HELP!! Two questions from <<the c programming language>>
- From: Guru Jois
- Re: HELP!! Two questions from <<the c programming language>>
- From: Tak
- HELP!! Two questions from <<the c programming language>>
- Prev by Date: Re: question about "++"
- Next by Date: Re: A good compiler please....
- Previous by thread: Re: HELP!! Two questions from <<the c programming language>>
- Next by thread: Re: HELP!! Two questions from <<the c programming language>>
- Index(es):
Relevant Pages
|