getline() a string giving difficulty

前端 未结 3 565
逝去的感伤
逝去的感伤 2020-12-22 13:00

i am doing a task where i am inputting ist no of times you want to have input and then i am inputting a full line by the use of getline but sime how i am not able to do that

3条回答
  •  感情败类
    2020-12-22 13:54

    for(j=1;j<=test;j++)     
    {          
    getline( cin,s);         
    len = s.length();         
    cout<

    This is reading in the int and the string with the one carridge return.

    It reads 1 as the total and then nothing as the string (hence the length of 0). Try 1TEST and this should give you a length of 4.

提交回复
热议问题