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

T

thuyptt

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: (e-mail address removed)

Sincerely and thanks,



Thanh Thuy
 
J

Jonathan Mcdougall

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 address removed)

No. Post here, read here.


Jonathan
 

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

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top