Re: HELP!! Two questions from <<the c programming language>>
- From: Tak <kakataka@xxxxxxxxx>
- Date: 31 May 2007 03:27:19 -0700
Algorithm trim_space
while EOF
do
begin
input char
if char = space then
begin
if flag = 0 then
begin
let flag = 1;
print char;
end
end
else
begin
let flag = 0
print char
end
end
goto step 2
end while
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?
.
- Follow-Ups:
- Re: HELP!! Two questions from <<the c programming language>>
- From: Guru Jois
- Re: HELP!! Two questions from <<the c programming language>>
- From: Ben Bacarisse
- Re: HELP!! Two questions from <<the c programming language>>
- References:
- Prev by Date: Re: A good compiler please....
- Next by Date: Re: HELP!! Two questions from <<the c programming language>>
- 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
|