Thanks for taking the time of reading my question. So I have this code:
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
float pricePerLetter = 0.0;
string userInput;
cout << "Welcome" << endl;
cout << "Please enter sentence: ";
getline(cin, userInput);
cout << userInput;
cout << "Please enter price per letter: ";
cin >> pricePerLetter;
cout << endl;
system("PAUSE");
return 0;
}
which runs fine. I am able to save the sentence on userInput and display it. However, when I switch fragments of the code for the one below, the program ends without letting me write the sentence.
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
float pricePerLetter = 0.0;
string userInput;
cout << "Welcome" << endl;
cout << "Please enter price per letter: ";
cin >> pricePerLetter;
cout << endl;
cout << "Please enter sentence: ";
getline(cin, userInput);
cout << userInput;
system("PAUSE");
return 0;
}
I don't get why this occurs.