473,394 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

michael maire ex1-22

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

Nov 14 '05 #1
3 1321
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
<20**************************@posting.google.com >

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.
aegis wrote:
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
--
E-Mail: Mine is a gmx dot de address.

Nov 14 '05 #2
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.

Nov 14 '05 #3
aegis wrote:

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.mccaugha...ks/uquote.html

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!

Nov 14 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Alan Kennedy | last post by:
Dear Pythonistas, One of our own, Michael Sparks, appears in an article in the October 2004 print edition of Personal Computer World, on the future of digital television and the digitisation of...
0
by: Tony Lavinio | last post by:
Dear com.text.xml XML community: It's hard to imagine a major company that doesn't have at least some systems running SQL Server, or using Microsoft XML technologies for that matter. Because of...
7
by: Calan | last post by:
Mike, Your code on the dynamic input checking was excellent and very well explained. (The only thing I had to do was change the test for text input to be "1 > len of text", instead or "0 >...
3
by: Bwalker252 | last post by:
Anyone with experience with this property? I seem unable to change it. I've been trying to use it with a simple text box, using the property options in the properties window and I've also tried...
7
by: El kroty | last post by:
Hi folks!! i'm trying to write k&r ex1-24 without a stack. I almost have it but there's a bug that makes me crazy and can't find it :'( whit some files it works and with others it doesn't. Here is...
0
by: UrsusMaximus | last post by:
www.awaretek.com/python/index.html features a Python411 interview with Michael Foord, aka Fuzzyman, Python hacker who has contributed a disproportionate amount and quality of open source projects,...
6
by: Ilias Lazaridis | last post by:
- Ï/Ç metaperl: Ilias Lazaridis: Michael Bayer wrote within: http://groups.google.com/group/sqlalchemy/msg/9d7a096a61abfc6f I understand your elaborations.
26
by: Ramon F Herrera | last post by:
http://groups.google.com/group/comp.lang.c/browse_frm/thread/86a3ddf0724d9630/4e38340aa824bee0?lnk=gst&q=how+to+best+parse+a+CSV&rnum=1#4e38340aa824bee0 http://tinyurl.com/29q4kf Michael & Paul...
1
by: Jackie Silva | last post by:
i want to apologize to Jerry Stuckle (jstuckle), Michael Fesser (netizen), Rik Wasmus (luiheidsgoeroe), Good Man (heyho), and anyone else who may have read this thread and found what I posted...
0
by: Mike Lalonde | last post by:
rke Michael Lalonde fought his enemy: a wild dog on an ironing board and went around killing rats with a jackhammer because his leg hurt and a heated argument arose which started a party, he made...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.