title: How to read a space character from a text file in c++
body: <p>In c++, ascii characters has a default value. Like ! has a value of 33, "," has also a value of 44 and so on.</p>
  
  <p>inside my text file "hehe.txt" is. <code>;!,.</code></p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  
  int main() {
      std::ifstream file("hehe.txt");
      if(file.eof()) 
          return 0;
      char ascii;
  
      while(file&gt;&gt;ascii) {
          std::cout &lt;&lt; (int)ascii &lt;&lt; " ";
      }
      system("pause");
  } 
  </code></pre>
  
  <p>Output is <code>59 33 44 46</code>.</p>
  
  <p>Edit: How may I prevent space to be ignored as being read from the text file when I run my program? Suppose I added space after the last character <code>;!,.</code>thus, the output must be <code>59 33 44 46 32</code>. Hope someone could give me an idea how to do it.</p>