Hey, im new to the C++ Language, and i got a book for X-mass (Accelerated C++) where it shows one of the easyest codes, but there is something strange with my console, it disapears after i type in my first name! what to do
Code:
#include <iostream>
#include <string>
int main()
{
// Ask for a persons name
std::cout << "Please enter your first name: ";
// Read the name
std::string name; // define name
std::cin >> name; // read into name
// Write a greetings
std::cout << " Greetings, " << name << "! have a whonder full time with accelerated c++" << std::endl;
return 0;
}
i tryied with cin.get() too but then the first letter in my name whont show
Code:
#include <iostream>
#include <string>
int main()
{
// Ask for a persons name
std::cout << "Please enter your first name: ";
std::cin.get();
// Read the name
std::string name; // define name
std::cin >> name; // read into name
std::cin.get();
// Write a greetings
std::cout << " Greetings, " << name << "! have a whonder full time with accelerated c++" << std::endl;
std::cin.get();
return 0;
}
any help would be apritiated