title: How to parse a file with blank spaces in c++?
body: <p>I have a file of format as:</p>
  
  <pre><code>2
  3 4
  7 8 9
  10 20 22 02
  ...
  </code></pre>
  
  <p>basically numbers in each line , separated by spaces.
  I have to read from the file, extract all numbers and maintain their line number too, as I have to make a tree later. I'm doing this to take input, but getting weird outputs.</p>
  
  <pre><code>#include&lt;cstdio&gt;
  #include&lt;iostream&gt;
  #include&lt;cctype&gt;
  using namespace std;
  
  void input()
  {
      char c,p;
      while(c=getchar()!=EOF)
      {
          if(c=='\n') printf("},\n{");
          else if(c==' ') printf(",");
          else if(c=='0')
          {
              p=getchar();
              if(p==' ')
              {
                  printf("%c%c,",c,p);
              }
              else
              {
                  printf("%c,",p);
              }
          }
          else if(isalpha(c))
          {
              printf("%c",c);
          }
      }
  }
  
  
  int main()
  {
      input();
  }
  </code></pre>
  
  <p>The image shows the input and output
  <img src="https://i.stack.imgur.com/Cr8QN.png" alt="enter image description here"></p>