473,385 Members | 1,830 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,385 software developers and data experts.

console.writeline and wordwrapping

using VS 2003

I have a console app and writing to the console looks ugly as the line wraps
at exactly 80 characters.

Short of counting every character, is there an easier way to format my
output to the console so that each line is intelligently broken at 80
characters or less when 80 characters falls within a word.

thanks
Nov 17 '05 #1
5 3592
Kevin,

Unfortunately no, there is no pre-set way of wrapping the text. You
will have to code this yourself. It shouldn't be too hard, since you know
you will always have 80 characters per line (as opposed to drawing on the
screen in non-fixed-width fonts).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"kevin" <ke***@discussions.microsoft.com> wrote in message
news:EE**********************************@microsof t.com...
using VS 2003

I have a console app and writing to the console looks ugly as the line
wraps
at exactly 80 characters.

Short of counting every character, is there an easier way to format my
output to the console so that each line is intelligently broken at 80
characters or less when 80 characters falls within a word.

thanks

Nov 17 '05 #2
Thanks for the reply Nicholas.

.... I'am typing right now.

Kevin

"Nicholas Paldino [.NET/C# MVP]" wrote:
Kevin,

Unfortunately no, there is no pre-set way of wrapping the text. You
will have to code this yourself. It shouldn't be too hard, since you know
you will always have 80 characters per line (as opposed to drawing on the
screen in non-fixed-width fonts).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"kevin" <ke***@discussions.microsoft.com> wrote in message
news:EE**********************************@microsof t.com...
using VS 2003

I have a console app and writing to the console looks ugly as the line
wraps
at exactly 80 characters.

Short of counting every character, is there an easier way to format my
output to the console so that each line is intelligently broken at 80
characters or less when 80 characters falls within a word.

thanks


Nov 17 '05 #3
Nicholas Paldino [.NET/C# MVP] wrote:
Unfortunately no, there is no pre-set way of wrapping the text. You
will have to code this yourself. It shouldn't be too hard, since you know
you will always have 80 characters per line (as opposed to drawing on the
screen in non-fixed-width fonts).


Ah, but my standard cmd prompt isn't 80 chars in width. I changed it
because I wanted more than that. If you're using .NET 2, it's become
real easy to get to the information about the Console window using
properties like Console.WindowWidth. If you're not on .NET 2, you'd have
to use the Win API function GetConsoleScreenBufferInfo - a bit more
complicated and possibly not worth the effort.

I'd say it depends: If you only want to output some long text, it's
probably just as well if it doesn't use the whole width (but poor people
who set their window to only 70 chars...). If you're writing an
application that actually works on the console interactively, you might
want to go to the trouble to make it work perfectly.

Oliver Sturm
--
omnibus ex nihilo ducendis sufficit unum
Spaces inserted to prevent google email destruction:
MSN oliver @ sturmnet.org Jabber sturm @ amessage.de
ICQ 27142619 http://www.sturmnet.org/blog
Nov 17 '05 #4
Oliver,

The OP stated he wanted it broken at 80 chars, but you bring up a good
point. =)
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Oliver Sturm" <ol****@sturmnet.org> wrote in message
news:u8****************@tk2msftngp13.phx.gbl...
Nicholas Paldino [.NET/C# MVP] wrote:
Unfortunately no, there is no pre-set way of wrapping the text. You
will have to code this yourself. It shouldn't be too hard, since you
know you will always have 80 characters per line (as opposed to drawing
on the screen in non-fixed-width fonts).


Ah, but my standard cmd prompt isn't 80 chars in width. I changed it
because I wanted more than that. If you're using .NET 2, it's become real
easy to get to the information about the Console window using properties
like Console.WindowWidth. If you're not on .NET 2, you'd have to use the
Win API function GetConsoleScreenBufferInfo - a bit more complicated and
possibly not worth the effort.

I'd say it depends: If you only want to output some long text, it's
probably just as well if it doesn't use the whole width (but poor people
who set their window to only 70 chars...). If you're writing an
application that actually works on the console interactively, you might
want to go to the trouble to make it work perfectly.

Oliver Sturm
--
omnibus ex nihilo ducendis sufficit unum
Spaces inserted to prevent google email destruction:
MSN oliver @ sturmnet.org Jabber sturm @ amessage.de
ICQ 27142619 http://www.sturmnet.org/blog

Nov 17 '05 #5

kevin wrote:
using VS 2003

I have a console app and writing to the console looks ugly as the line wraps
at exactly 80 characters.

Short of counting every character, is there an easier way to format my
output to the console so that each line is intelligently broken at 80
characters or less when 80 characters falls within a word.

thanks


Have a google for 'pretty print'. You will probably find many
implementations in C/C++, which given that you are just doing console
output, should be easily translatable.

I'm sure there are many many ex-CS students who were forced to write
pretty printers in most every language under the sun...

--
Larry Lard
Replies to group please

Nov 17 '05 #6

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

Similar topics

4
by: jabailo | last post by:
This is driving me crazy. I finally got the Remoting sample chat application working almost. When I run the chat client in VS.NET it goes into an endless loop -- that's because I assume that...
1
by: Oz | last post by:
This is long. Bear with me, as I will really go through all the convoluted stuff that shows there is a problem with streams (at least when used to redirect stdout). The basic idea is that my...
7
by: shawnk | last post by:
Hello Everyone How do you format format numbers right-justified using Console.WriteLine(), i.e I need to line up numbers in vertical columns and the MSDN documentation is pretty poor Here is the...
5
by: Publicjoe | last post by:
I am working on a little app which uses colour in the console window. I have created a class to extend the console functionality but the ClearScreen method does not work correctly. I am enclosing a...
17
by: MumboJumbo | last post by:
Hi I have a really basic question hopefully some can help me with: Can you write a (i.e. one) C# project that works from the cmd line and gui? I seems if i write a GUI app it can't write to...
5
by: portroe | last post by:
Hi I am using console.Writeline in my simple program. I do not however see anything happening in the output window when I debug, there are also no error messages, Has anybody a tip on what...
2
by: djc | last post by:
out of all the overloads that pop up via intellisense for console.writeline() the following one confuses me: Console.WriteLine (string format, params object arg) 1) whats the deal with...
1
by: John Wright | last post by:
I am running a console application that connects to an Access database (8 million rows) and converts it to a text file and then cleans and compacts the database. When it runs I get the following...
0
by: Stephen Thomas | last post by:
Hi there I wonder if any one has encountered this problem or can suggest what is wrong. I am trying the a procedure from the msn site but get the following message: Error 1 The type or...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.