Wie kann ich in C ++ zeilenweise über cin iterieren?
Ich möchte noch einmal wiederholenstd::cin
Zeile für Zeile, wobei jede Zeile alsstd::string
. Welches ist besser:
string line;
while (getline(cin, line))
{
// process line
}
oder
for (string line; getline(cin, line); )
{
// process line
}
? Was ist der normale Weg, um dies zu tun?