title: Extracting string data using getline function and writing each line into separate files using ofstream function
body: <p>My input file stored in the txt format is some thing like:</p>
  
  <pre><code>data1 : 15 16 20 23 56
  data2 : 15 65 89 64 65
  </code></pre>
  
  <p>so, I'm extracting the each line into string format into a separate files like below</p>
  
  <p>Macro definition:</p>
  
  <pre><code>    #define STRINGIFY_INIT(x)  #x
      #define STRINGIFY(x)  STRINGIFY_INIT(x)
  
      #define FILE_PREFIX   data
      #define FILE_EXT      .txt
  
      #define CONCAT_FILE(a) STRINGIFY(FILE_PREFIX) STRINGIFY(a) STRINGIFY(FILE_EXT)
  </code></pre>
  
  <p>Code Starts something like this:</p>
  
  <pre><code>    std::string line;
  
      std::ifstream readfile;
      readfile.open("read.txt");
  
      while(getline(readfile,line)){
        int x = 1;
        std::ofstream outputFile( CONCAT_FILE(x) );
        outputFile &lt;&lt; line &lt;&lt;std::endl;
        std::cout&lt;&lt;line&lt;&lt;std::endl;
        x++;
      }
  </code></pre>
  
  <p>Now, this code creates the file called "datax.txt" and in the text file, it is the last extracted data from the inputfile is present.i.e,</p>
  
  <pre><code>data2 : 15 65 89 64 65
  </code></pre>
  
  <p>But, my requirement is it to create 2 files with name data1.txt and data2.txt, as there 2 lines of data present in the original input file.</p>
  
  <p>The problem, I'm having is in the line:</p>
  
  <pre><code>    std::ofstream outputFile( CONCAT_FILE(x) );
  </code></pre>
  
  <p>the expression "CONCAT_FILE(x) ", is not taking the value of x, but it is simply taking ASCII character "x".So, a single file with the name "datax.txt" is created and not "data1.txt","data2.txt".</p>
  
  <p>I expected to work like, CONCAT_FILE(1) for the first iteration and CONCAT_FILE(2) for the next iteration, so that 2 files "data1.txt","data2.txt" are created.</p>
  
  <p>Could any one please help me out.</p>
  
  <p>I need to create 2 separate files, so that i can read only integer values separately and want to calculate mean for each of them.</p>
  
  <p>Please do the needfull.
  Thanks,</p>