Re: HELP!! Two questions from <<the c programming language>>



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

.



Relevant Pages

  • new syslogd option for adding local timestamp
    ... I ported the -T option from netbsd syslogd.c to freebsd syslog. ... "Add a -T flag to syslogd, which causes it to use local time for ... -printline(const char *hname, char *msg) ... +Always use the local time and date for messages received from the ...
    (freebsd-hackers)
  • [UNIX] Cyrus Sieve / libSieve Buffer Overflow
    ... These overflows allow remote attackers to cause ... Problem comes when giving the script a>100 chars long corrupted header ... name,>100 chars long IMAP flag or a script that contains lots of errors ... to overflow the 500 char limit in error message. ...
    (Securiteam)
  • Re: [RFC] cpuset relative memory policies - second choice
    ... the mpol_nodemask_mode already is char. ... It doesn't manage this flag ... get_mempolicy call was to reduce the likely rate of bugs in user ... a bitmask that they calculated using Choice B node numbering, ...
    (Linux-Kernel)
  • [RFC/PATCH] Per-device parameter support (4/16)
    ... They appear as boolean parameter to the outside, ... specified flag to flags when the specified boolean value is 1 and 0 ... +int param_array(const char *name, const char *val, ...
    (Linux-Kernel)
  • Re: HELP!! Two questions from <>
    ... if char = space then ... No declaration for `flag`; hence, ... You don't need `goto` for this problem, ...
    (comp.lang.c)