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

Discussion in 'C++' started by thuyptt@dsp.com.vn, Dec 6, 2005.

  1. Guest

    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:

    Sincerely and thanks,



    Thanh Thuy
     
    , Dec 6, 2005
    #1
    1. Advertising

  2. 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:


    No. Post here, read here.


    Jonathan
     
    Jonathan Mcdougall, Dec 6, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mitchua
    Replies:
    5
    Views:
    2,807
    Eric J. Roode
    Jul 17, 2003
  2. Sam
    Replies:
    3
    Views:
    14,173
    Karl Seguin
    Feb 17, 2005
  3. Replies:
    5
    Views:
    681
    John W. Kennedy
    Jan 11, 2007
  4. Replies:
    6
    Views:
    183
    Bob Barrows [MVP]
    Aug 17, 2006
  5. damezumari
    Replies:
    18
    Views:
    546
    Richard Cornford
    Dec 20, 2006
Loading...

Share This Page