michael maire ex1-22

A

aegis

i think you misinterpreted the problem statement.
your suggestion seems to coincide with other
solutions where people stick newlines in the
line to act as a separator. but going this
route does not exhibit proper behavior when
your column width is very small. so this approach
can not be correct. also, if your input is
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
and the line is greater than column width
the line should be broken up into smaller segments
independent of column width. your solution also
eliminates spaces from the line.

if my column width is five and I have the line
"Hello World!"

then my output should be
"
Hello\n
Worl\n
d!\n
"

the space is *part* of the line and should not be
omitted.

here is a solution that I have looked at:
http://users.powernet.co.uk/eton/kandr2/krx122.html

it is a piece of junk. it can't even handle lines
longer than 120 characters.
again
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" is a line
and this program doesn't fold it and will also
segfault on lines larger than 120 characters.

[aegis@pluto ~] perl -e 'print "A" x 120' | ./krx122
Segmentation fault (core dumped)
[aegis@pluto ~]

see? piece of junk
 
M

Michael Mair

Hello aegis,


one thing first: Please respond in the same thread -- there
may be other who can help you but are not aware what you
are referring to.
Whoever is interested: Start at the Message ID
<[email protected]>

If you answer, then quote enough of the message you are
answering.

Apart from that, I do not think that a misspelled version
of my name is a decorative ingredient of subject lines.

i think you misinterpreted the problem statement.
your suggestion seems to coincide with other
solutions where people stick newlines in the
line to act as a separator. but going this
route does not exhibit proper behavior when
your column width is very small. so this approach
can not be correct. also, if your input is
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
and the line is greater than column width
the line should be broken up into smaller segments
independent of column width. your solution also
eliminates spaces from the line.

Well, the code I gave a link to does exactly what I propose
for line widths from 1 to INT_MAX-1.
About the spaces: Yes, I explicitly mention that I am of the
opinion that this is a cleaner solution. If you want to leave
the spaces in there: This actually simplifies everything, so
I do not see a problem there.

You asked whether you were interpreting the task description
in the right way and I responded that I think it describes
what I proposed.

if my column width is five and I have the line
"Hello World!"

then my output should be
"
Hello\n
Worl\n
d!\n
"

the space is *part* of the line and should not be
omitted.

Why? And why did you omit the space here if it is so
essential?

here is a solution that I have looked at:
http://users.powernet.co.uk/eton/kandr2/krx122.html

it is a piece of junk. it can't even handle lines
longer than 120 characters.
again
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" is a line
and this program doesn't fold it and will also
segfault on lines larger than 120 characters.

[aegis@pluto ~] perl -e 'print "A" x 120' | ./krx122
Segmentation fault (core dumped)
[aegis@pluto ~]

see? piece of junk

And how exactly does this relate to your code?

IMO, it comes down to that:
Either you are happy with your code, read my comments
about it and go on to the next exercise or you try to
implement what I suggested and come back if you need
help or a code review.


-Michael
 
A

aegis

Write a program to ``fold'' long input lines into two or more shorter
lines after the last non-blank character that occurs before the n-th
column of input. Make sure your program does something intelligent with
very long lines, and if there are no blanks or tabs before the
specified column

where does it state that we should omit spaces in the line?
we only ensure that there is no space before the nth column.
which doesn't mean we omit spaces within the line.
the space can very well start at the beginning of the most newest line.
The "specified" column in the last sentence refers to the column
before the nth column. I think you read text that wasn't there.
your code uses stuff not introduced in the first chapter.
 
C

CBFalconer

aegis said:
Write a program to ``fold'' long input lines into two or more shorter
.... snip ...

Here you at least generated a reply to the previous article, but
you failed to quote any context. You should always quote enough so
that the article stands on its own, but please do not overquote,
i.e. snip anything that is not germane to your reply. Maintain
attribution lines for anything you quote.

Here are a few useful references. Read at least some of them.

http://www.caliburn.nl/topposting.html
http://www.netmeister.org/news/learn2quote.html
http://www.catb.org/~esr/faqs/smart-questions.html
http://www.greenend.org.uk/rjk/2000/06/14/quoting.html
http://www.i-hate-computers.demon.co.uk/
http://web.ukonline.co.uk/g.mccaughan/g/remarks/uquote.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top