title: How to read number of characters stored in input stream buffer
body: <p>I have a quick question - how can I possibly write something in console window to <code>std::cin</code> without assigning it to a <code>string</code> or <code>char[]</code>? And then how to read the number of characters that are stored in buffer?</p>
  
  <p>Let's say that I want to create an array of <code>char</code>, but it shall has the size of the input length. I might create a buffer or a variable of big size to store the input and then read its length, allocate memory to my char array and copy it. But let's also say that I am a purist and I don't want any additional (other than stream buffer) memory used. Is there a possibility to access <code>std::cin</code> buffer, read the number of characters stored and copy them to my array? I was trying to find the answer for several hours, reading cpp reference but I really couldn't find solution. I couldn't even find if there is a possibility to write something to <code>std::cin</code> buffer without assigning it to a variable, aka executing <code>cin &gt;&gt; variable</code>. I would appreciate any help, also if you have alternative solutions for this problem.</p>
  
  <p>Also, does somebody know where can I find information about how buffers work (means where computer stores input from keyboard, how it is processed and how iostream works with computer to extract data from this).</p>
  
  <p>Many thanks!</p>