Re: HELP!! Two questions from <<the c programming language>>
- From: Guru Jois <guru.jois@xxxxxxxxx>
- Date: 31 May 2007 02:22:27 -0700
On May 31, 1:55 pm, Tak <kakat...@xxxxxxxxx> wrote:
No, that's not how it works here. You post your attempt, we help you
with problems. We don't do homework.
--
Ian Collins.
No, I think you are misunderstanding.
It's not homework;
I can't work out Exercise 1-9.
My code of Exercise 1-10 is like this:
#include <stdio.h>
main()
{
char c;
while ((c = getchar()) != EOF)
{
if (c == '\t')
printf("\\t");
else if (c == '\b')
printf("\\b");
else if (c == '\\')
printf("\\\\");
else
putchar(c);
}
}
I don't know whether it's right or not?
everything is ok...why don't you run this and see?
why you can't work out 1-9 ?? I can give you idea, you implement it.
accept the char.. if it is a space set a flag saying you got one
space. you should ignore further spaces if this flag is set, otherwise
display further chars.
Continue this till eof.
Huuuh...didn't get idea???? Follow the step
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
Bye
Guru Jois
.
- Follow-Ups:
- Re: HELP!! Two questions from <<the c programming language>>
- From: Tak
- Re: HELP!! Two questions from <<the c programming language>>
- From: Chris Dollin
- Re: HELP!! Two questions from <<the c programming language>>
- References:
- Prev by Date: Re: HELP!! Two questions from <<the c programming language>>
- 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
|