Pourquoi cin.getline commence-t-il à travailler sur la deuxième ligne de l'entrée du corps, mais se casse la première?cin.getline saute une ligne d'entrée et passe à la suivante
exécuter le programme Exemple:
Enter name: Will
Enter body: hello world
hello again <= It accepts this one
char* name = new char[100];
char* body = new char[500];
std::cout << "Enter name: ";
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
std::cin.getline(name, 100);
std::cout << "Enter body: ";
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
std::cin.getline(body, 500');
std::cin >> body;
Que voulez-vous dire qu'il ne fonctionne pas? –