Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > How to display a string in many lines, each lines have a specified length

Reply
Thread Tools

How to display a string in many lines, each lines have a specified length

 
 
thuyptt@dsp.com.vn
Guest
Posts: n/a
 
      12-06-2005
Hi you!!

I am programming a part of my application and I met a trouble in
display test.

I used fgets to read each line in a text file and display all lines on
the screen. But the size of the window are too small to display all the
line(208,320), So can I ask you how to divide split a string(a line in
file) into many lines and dis play them on the screen so that all the
characters of the string would be displayed fully.


I am looking forward to your support!!

Can you contact me via my email: http://www.velocityreviews.com/forums/(E-Mail Removed)

Sincerely and thanks,



Thanh Thuy

 
Reply With Quote
 
 
 
 
Jonathan Mcdougall
Guest
Posts: n/a
 
      12-06-2005
(E-Mail Removed) wrote:
> Hi you!!
>
> I am programming a part of my application and I met a trouble in
> display test.
>
> I used fgets to read each line in a text file and display all lines on
> the screen. But the size of the window are too small to display all the
> line(208,320), So can I ask you how to divide split a string(a line in
> file) into many lines and dis play them on the screen so that all the
> characters of the string would be displayed fully.


I assume you are using some kind of "console" window for your
application. A console usually wraps the text if it extends past the
end of the line.

However, you may get a substring of the length you want:

# include <string>
# include <iostream>

int main()
{
std::string s("a long long long line");
std::cout << s.substr(0, 10); // prints "a long lon"
}

And you can "pause" by adding a

std::cin.get();

whenever X lines are printed.

> Can you contact me via my email: (E-Mail Removed)


No. Post here, read here.


Jonathan

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
String exceeding length - Getting absolute string length james.w.appleby@gmail.com Java 5 01-11-2007 12:07 AM
List Many to Many results once each? andrewrubie@hotmail.com ASP General 6 08-17-2006 02:45 PM
Asp.Net Calender, how to display 5 lines if there are only 5 lines in one month? Jack ASP .Net 9 10-12-2005 03:44 AM
left(string, length) or right(string, length)? Sam ASP .Net 3 02-17-2005 12:01 PM



Advertisments