Hey, i just start working with string and i am totally noob =). So i would like to ask you if you can help me... I have some programs to write, but i have a little problems to get the code working...

Ok first question is, how do i make a program, that will ask a user to input 10 lines of text.

void lines(string lines)
{
   for (int i=0; i<10; i++)
   {
      cout<<"Line "<<i+1<<": ";
      getline(cin, lines);
      cout<<endl;
       
   }

    
}

I wrote it like this. With this code i could write 10 lines of text, but the line here ends when i press enter(running in cmd). I would like that the lines will count, not when i press enter, but when the text goes in new line(because it is at the end of the cmd window). Is this possible?

I hope you understad what i ment =)

ps
----------
sry for my bad english =)

That's not possible. Why? One reason is that getline() doesn't know, or care, what the size of the command window is. It reads everything up to the '\n', or some other character you specify.

Member Avatar

HASHMI007

#include<iostream.h>
#include<conio.h>
void lines(char );
void lines(char string_lines[100])
{
for (int i=0; i<10; i++)
    {

cout<<"Line "<<i+1<<": ";
cin>> string_lines;

}

}
void main()
{
char string_lines[100];

lines(string_lines);

}