I am writing a void function the goes through a loop and each time it reads the whole line and saves it as text but when I run the program I get an empty line then the input mince the last line in the input is there any way to remove the empty line and print all the lines that I give to the stdin
#include <iostream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <algorithm>
void cap_tag(int n){
for ( int i = 0; i < n ; i++ ){
std::string text;
std::getline(std::cin , text );
std::cout <<text << std::endl;
}
}
int main(){
int n , q ;
std::cin >> n >> q;
std::cout << n << " " << q << std::endl;
cap_tag(n);
return 0;
}
my input : 4 3
hello world
my l0v3 !$ lisa @nn
what is wrong with this 5555
any-thing is not printed
random stuff
random stuff
random stuff
output : 4 3
hello world
my l0v3 !$ lisa @nn
what is wrong with this 5555