getline not working c++

C++
cin >> num;
cin.clear(); //clear the error bits for the cin input stream
cin.sync(); //synchronize the input buffer, discarding any leftover characters in the buffer int num = 0;
cout << "Enter a number: ";
cin >> num;

cout << "You entered " << num << endl;
cin.get(); //this should make it pause 
Source

Also in C++: