For anyone facing this issue:
The issue occurs because the std streams such as cin and cout are not buffered by default, to allow you to use functions from cstdio such as printf() alongside objects from iostream such as cout. You can enable buffering as follows:
std::ios_base::sync_with_stdio(false);
As for the OP's code and also as an example of using readsome(), you should try using readsome() as follows:
#include <iostream>
#include <string>
using namespace std;
int main () {
std::ios_base::sync_with_stdio(false);
char* s = new char[10];
string str;
bool yn;
int num;
cout << "Do you want to readsome? (0/1): ";
cin >> yn;
cout << "Feed me: ";
cin >> num;
if(yn) cin.readsome(s, 10);
cout << "You fed me: ";
cout << num;
if(yn) cout << "\nThe leftovers are: " << s;
return 0;
}
Example run:
Do you want to readsome? (0/1): 1
Feed me: 12abc
You fed me: 12
The leftovers are: abc
In the unlikely event this code fails to run for you (make sure you are not giving EOF or blank space input, cin.fail() and cin.bad() are unlikely but you can check them), it may be for the reasons kwierman mentions.