Textinput with more than one line

Discussion in 'C++' started by Jean Pierre Hort, Sep 17, 2005.

  1. Hi,
    I am going to write a kind of editor for Linux.
    It is one of my first projects so I'm not having much experience.

    It work's very good, I can chose a filename, if this file exists text
    will be written at the end of this file, if it does not exist this file
    will be created.

    My problem now is, I get the text of the user which should be written
    into the file via "cin >> var". This var will then be written into the
    file. But, I can only do one line, when I press enter for making a new
    line the text will be send to the cin.
    Is there an easy way to put a text with more than one line into a
    stringvariable? So that I can press enter more than one time for
    creating numerous endls? The input should be ended when entering EOF or
    something like that.

    Is there an easy way realising that?

    Regards
    Jean Pierre Hort, Sep 17, 2005
    #1
    1. Advertising

  2. Jean Pierre Hort wrote:
    > Hi,
    > I am going to write a kind of editor for Linux.
    > It is one of my first projects so I'm not having much experience.
    >
    > It work's very good, I can chose a filename, if this file exists text
    > will be written at the end of this file, if it does not exist this file
    > will be created.
    >
    > My problem now is, I get the text of the user which should be written
    > into the file via "cin >> var". This var will then be written into the
    > file. But, I can only do one line, when I press enter for making a new
    > line the text will be send to the cin.
    > Is there an easy way to put a text with more than one line into a
    > stringvariable? So that I can press enter more than one time for
    > creating numerous endls? The input should be ended when entering EOF or
    > something like that.
    >
    > Is there an easy way realising that?
    >
    > Regards


    If you what to get input until EOF then just read one character at a
    time until EOF and append each char to the string.

    string text;
    char ch;
    while (cin.get(ch))
    text += ch;

    john
    John Harrison, Sep 17, 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. Merciadri Luca
    Replies:
    4
    Views:
    809
  2. Rolf Rosenquist

    Strange textinput

    Rolf Rosenquist, Oct 5, 2005, in forum: ASP General
    Replies:
    4
    Views:
    91
    Rolf Rosenquist
    Oct 6, 2005
  3. simplicity

    Forcing onChange event on textinput

    simplicity, Oct 1, 2007, in forum: Javascript
    Replies:
    5
    Views:
    214
    David Mark
    Oct 2, 2007
  4. Steven D'Aprano
    Replies:
    0
    Views:
    90
    Steven D'Aprano
    Dec 23, 2013
  5. Replies:
    3
    Views:
    82
    Gary Herron
    Dec 23, 2013
Loading...

Share This Page