I also notice the list is std::string but OP is reading into char[]
Why did the OP use std::string in the first code and char[] in the second?
This code should work:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
void inputf(std::list<std::string>& L)
{
std::string input;
std::string::size_type lines = 0;
std::cout << "How many lines do you want to enter: ";
std::cin >> lines;
for(std::string::size_type ins = 0; ins < lines; ++ins)
{
std::cout << "Enter a line: ";
std::getline(std::cin, input);
L.push_back(input);
}
}
Also, container::size_type instead of size_t is preferred for maximum portability. And you should stay consistent; you didn't add the std namespace qualifier on line 1.
There is a mistake in your code. On lines 12 & 13lines should be input.