473,748 Members | 3,697 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

text-formatting program c++ problem

Any one know how to do this? thank
Write a simple text-formatting program that produces neatly printed
output from input text containing embedded command lines that
determine how to format the output; all lines begin with a period are
command lines. The task of the program is to collect words from input
lines, fill output lines with those words, adjust the margins, and
print the result. Your programs should handle the commands shown in
Table 1 and should make use of functions.
Table 1 Text formatting commands for Lab #2
Command

..ce n
..ce
..in ±n
..in n
..in
..po ±n
..po n
..po
..ll n
..ll
..ls n
..ls
..sp n
..sp
..ad
..na
Description

Centre the next n lines (n might be 0)
Centre the next line
Increase (decrease) the indentation by n spaces
Set the indentation to n spaces
Reset indentation to default (0 spaces)
Increase (decrease) the left margin (page offset) by n spaces
Set the left margin (page offset) to n spaces
Reset margin to default (10 spaces)
Set line length to n spaces
Reset line length to default (100 spaces)
Set interline spacing to n (n = 2 gives double spacing)
Reset to single spacing
Put (n * CurrentLineSpac ing) blank lines in the output
Put (1 * CurrentLineSpac ing) blank lines in the output
Start adjustment of right margin (default; works in fill mode only)
Stop adjustment of right margin
When the program is filling output lines with input words, it is said
to be operating in fill mode. When not operating in fill mode, lines
should be printed exactly as they appear in the input. When operating
in fill mode, the program also may have to pad each output line evenly
with blank characters to produce a straight right margin; the program
is said to be operating in adjust mode when operating in this manner.
When not in adjust mode, the program will fill output lines but the
right margin will be jagged.

Your program should begin execution using the following default
values: line length is 100 characters, line spacing is 1 (single
spacing), margin is 10 characters, indentation level is 0 characters.
The program begins execution in fill mode, adjusting the right margin.
These defaults should remain in effect until changed by the
appropriate commands. A period, question mark, or exclamation point
should be followed by 2 blank spaces in the output, unless it is at
the end of an output line. A new paragraph should be separated from
the previous by an extra CurrentLineSpac ing lines.
Jul 23 '05 #1
6 2978

"shoo" <yu******@gmail .com> wrote in message
news:1a******** *************** ***@posting.goo gle.com...
Any one know how to do this?
Yes.
thank


You're welcome.

[snip homework assignment, not accompanied
by any evidence of an attempt]

-Mike
Jul 23 '05 #2

"shoo" <yu******@gmail .com> wrote in message
news:1a******** *************** ***@posting.goo gle.com...
Any one know how to do this? thank
Write a simple text-formatting program that produces neatly printed

Read this:
http://www.parashift.com/c++-faq-lit...t.html#faq-5.2

Regards,
Sumit.
--
Sumit Rajan <su*********@gm ail.com>
Jul 23 '05 #3

"shoo" <yu******@gmail .com> schreef in bericht
news:1a******** *************** ***@posting.goo gle.com...
Any one know how to do this? thank
Write a simple text-formatting program that produces neatly printed
output from input text containing embedded command lines that
determine how to format the output; all lines begin with a period are
command lines. The task of the program is to collect words from input
lines, fill output lines with those words, adjust the margins, and
print the result. Your programs should handle the commands shown in
Table 1 and should make use of functions.
Table 1 Text formatting commands for Lab #2
Command

.ce n
.ce
.in ±n
.in n
.in
.po ±n
.po n
.po
.ll n
.ll
.ls n
.ls
.sp n
.sp
.ad
.na
Description

Centre the next n lines (n might be 0)
Centre the next line
Increase (decrease) the indentation by n spaces
Set the indentation to n spaces
Reset indentation to default (0 spaces)
Increase (decrease) the left margin (page offset) by n spaces
Set the left margin (page offset) to n spaces
Reset margin to default (10 spaces)
Set line length to n spaces
Reset line length to default (100 spaces)
Set interline spacing to n (n = 2 gives double spacing)
Reset to single spacing
Put (n * CurrentLineSpac ing) blank lines in the output
Put (1 * CurrentLineSpac ing) blank lines in the output
Start adjustment of right margin (default; works in fill mode only)
Stop adjustment of right margin
When the program is filling output lines with input words, it is said
to be operating in fill mode. When not operating in fill mode, lines
should be printed exactly as they appear in the input. When operating
in fill mode, the program also may have to pad each output line evenly
with blank characters to produce a straight right margin; the program
is said to be operating in adjust mode when operating in this manner.
When not in adjust mode, the program will fill output lines but the
right margin will be jagged.

Your program should begin execution using the following default
values: line length is 100 characters, line spacing is 1 (single
spacing), margin is 10 characters, indentation level is 0 characters.
The program begins execution in fill mode, adjusting the right margin.
These defaults should remain in effect until changed by the
appropriate commands. A period, question mark, or exclamation point
should be followed by 2 blank spaces in the output, unless it is at
the end of an output line. A new paragraph should be separated from
the previous by an extra CurrentLineSpac ing lines.


Hi,

Pay me $5.000 and I do for you

John
Jul 23 '05 #4
Johan wrote:
"shoo" <yu******@gmail .com> schreef in bericht
news:1a******** *************** ***@posting.goo gle.com...
Any one know how to do this? thank
Write a simple text-formatting program that produces neatly printed
output from input text containing embedded command lines that
determine how to format the output; all lines begin with a period are
command lines.
[snip -- homework assignment details]

Hi,

Pay me $5.000 and I do for you

John


Was that five dollars (accurate to 1/10 cent) or
was that five thousand dollars?

I wouldn't do this for five dollars since that barely
covers the cost of the frustration in transmission
of the product.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.l earn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library

Jul 23 '05 #5
shoo wrote:
Any one know how to do this? thank

[snip -- homework assignment]

When asking for people to write your homework
assignment, it is customary to provide the
following information:

1. Instructor's email address
Homework assignments will be directly emailed
to you and the instructor to make sure there
is no corruption of the provider's material.
See "fraud".

2. Instructor's office phone number.
Include the country code.
The provider of the homework will want to
verify receipt of the homework from the
instructor.

The above information is also required in case
clarification is needed about the assignment.

3. Bartering / Payment suggestions.
Guaranteed payment will produce better work
from the homework provider. The higher the
payment, the better the work.

4. The due date of the assignment.
The provider needs to know when to deliver
the product. The more advanced notification,
the cheaper the price of the product or service.

Evil[1] and bad things will happen if any of the above
is left out.

***** EXCEPTION TO ABOVE RULES *****
Posting your assignment, along with your effort
or work will grant you free assistance and none
of the above is required. Read the FAQs below
on how to post.

------
[1] Some kinds of evil in a homework product are
1. Obfuscation -- Search web for "obfuscated code contest"
2. Using advanced topics or techniques.
3. Coding using assembly language.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.l earn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library

Jul 23 '05 #6
shoo wrote:

Any one know how to do this? thank


The first thing you need to do is to define tasks you need
to do in order to solve the whole assignment. Don't get frustrated
by the complexity but break that complexity down into managable
chunks.

The first thing I notice in this assignment is that obviously
you have some sort of input. This input is organized into lines.
Those lines can be of 2 types, depending on the first character of
that line:
data lines
command lines

So your first subtask could be:
read the input and differentiate between those 2 types of input
lines.

That's your first subgoal in doing that assignment. When you reached that
goal, study the assignment again and decide what your next subgoal should
be, etc.. until the whole assignment is done.

--
Karl Heinz Buchegger
kb******@gascad .at
Jul 23 '05 #7

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

Similar topics

1
4162
by: joes | last post by:
Hello there ! I rendering a PDF with XSLT using Xalan and FOP. I like to place in my article an image, so that the text is floating around the image. I tried several things but it didn't work so far. I found some hints that it should work with "fo:float" but it seems not to work with apache's FOP, so has anybody out there any solution and experience ? example:
2
2293
by: Jiri Palecek | last post by:
I have a question on web authoring (probably HTML+CSS). Is it somehow possible to put two words above each other inside a paragraph so the result would be valid and render at least in Mozilla? I mean this: text text text text text text text text text text text text text text text text text text text text text text text text | is | text text text txt | | text text text text ...
2
3049
by: Buddy Ackerman | last post by:
Apparently .NET strips these white space characters (MSXML doesn't) regardless of what the output method is set to. I'm using <xsl:text> </xsl:text> to output a tab character and <xsl:text> </xsl:text> to output a carriage return and line feed but they get stripped at some point. I'm passing a StringWriter to the XslTransform.Transform method. Anyway to get this to actually output the tab and carriage and line feed characters?
6
4209
by: Lance Geeck | last post by:
I have a simple form where I am using a dataset called Client. On the data entry screen, there are name, address, city state and zip. I have the fields bound to the dataset field. (Properties screen: Data bindings then Text ) When I run the program and make a change to an existing record in the City text box, the Dataset value for this column is changed as expected. When I check the HasChanges property it says false. I don't...
3
2607
by: jweinberg1975 | last post by:
I would like for users to be able to select from a small number of options that come from a little drop down menu which then closes. .. http://www.geocities.com/jweinberg1975/dropdown_on_text00.html .. In order to see the behavior you should "mouseover" the white-on-black text segment that says "omnis dolor repellend" .. the thing is that I don't want for the whole space in the paragraph to be empty. I just need for the little menu to...
3
2177
by: bbepristis | last post by:
Hey all I have this code that reads from one text file writes to another unless im on a certian line then it writes the new data however it only seems to do about 40 lines then quits and I cant figure out why any help would be much apprechiated 1. Dim line_num As Integer 2. Dim filename2 As String 3.
3
4009
by: acecraig100 | last post by:
I am fairly new to Javascript. I have a form that users fill out to enter an animal to exhibit at a fair. Because we have no way of knowing, how many animals a user may enter, I created a table with a createElement function to add additional entries. The table has the first row of input text boxes already in it. You have to click a button to add another row. That seems to be working fine. How do I pull the information from the input boxes...
3
2661
by: jonniethecodeprince | last post by:
Hi all, I have trouble getting an array of data stored in a separate javascript file i.e. a file called books.js into a table of data for a .xhtml file. There are 50 Records in this file. There are 5 colums of data I wish to display. I want to display these records in groups of 10. Based on the fact that the records I want are located in a separate file, how can I get these details to show on the form and manipulate the data to...
10
3220
by: bluemountain | last post by:
Hi there, Iam new to python forms and programming too I had a text file where i need to extract few words of data from the header(which is of 3 lines) and search for the keyword TEXT1, TEXT2, TEXT3in entire file(file consisting of 150 lines) that is related to a particular id and get the sum of the, WRITES of TEXT1, TEXT2, TEXT3 ex: input file will be as below Windows 2000 text text text text text text text
2
2117
by: dpw.asdf | last post by:
I have been searching all over for a solution to this. I am new to Python, so I'm a little lost. Any pointers would be a great help. I have a couple hundred emails that contain data I would like to incorporate into a database or CSV file. I want to search the email for specific text. The emails basically look like this:
0
8989
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8828
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9537
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9319
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9243
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6795
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4599
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2213
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.