Consider this code:
#include <iostream>
#include <string>
using namespace std;
int main(){
int n = 1;
string data[13];
while(n > 0){
cin >> n;
for(int i = 0; i < n; i++){
getline(cin,data[i]);
cout << data[i] << endl;
}
}
}
i compiled this in cppdroid on my android. I want to hold n lines in the array. (n <= 13). Everything is fine about that. But when I input an integer in the first line of program, it prints one blank line and on the third line the program takes input for lines. My console window looks like this:
2
This is line 1.
This is line 1.
And this is line 2.
And this is line 2.
I want to remove unwanted spaces.