Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Textinput with more than one line

Reply
Thread Tools

Textinput with more than one line

 
 
Jean Pierre Hort
Guest
Posts: n/a
 
      09-17-2005
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
 
Reply With Quote
 
 
 
 
John Harrison
Guest
Posts: n/a
 
      09-17-2005
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
 
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
Can one declare more than one signal on one line? Merciadri Luca VHDL 4 11-01-2010 02:00 PM
Like all great travelers, I have seen more than I remember andremember more than I have seen. shenrilaa@gmail.com C++ 0 03-05-2008 08:41 AM
Like all great travelers, I have seen more than I remember andremember more than I have seen. shenrilaa@gmail.com C Programming 0 03-05-2008 03:26 AM
Forcing onChange event on textinput simplicity Javascript 5 10-02-2007 01:57 AM
Strange textinput Rolf Rosenquist ASP General 4 10-06-2005 07:11 PM



Advertisments