Read txt file

Hi everyone,
I have txt file with 3 columns (3.1, 3.2, 3.3) and 2048 rows. I want to read code in order to:
1. read txt file and write in the new txt file
2. in the new txt file consist of 2 columns (2.1, 2.2) and 2048 rows. The 2.1 = 3.2/3.1 and 2.2 = 3.3. The row don't change.

My code (i used devC++)
// danh gia anh huong multi va single
#include <iostream>
#include <conio.h>
#include <ostream>
#include <fstream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
string line;
int j;
// float energy, channel, count, bin;
float a[j];
float bin[j];
float count[j];

// read file txt from folder
ifstream data_total ("F:/compton research-data/Data_28_July_15/Scat_100_TAr_50_PC30_150/data_100.txt");
if (data_total.is_open())
{
while ( getline (data_total,lines))
{
for (j = 1; j <= 2; j++)
{
bin[j] = ++a[j+1]/a[j];
count[j] = ++a[j+2];

}}
cout << line << bin[j] << count[j] <<endl;
}
else cout <<"can not open file";
data_total.close();
// data_single.close();
// data_multi.close();

// write to txt file
ofstream data;
data.open ("F:/compton research-data/Data_28_July_15/Scat_100_TAr_50_PC30_150/data_100_c.txt");
cout << "\n---writing---" <<endl;
data.close();
getch ();
return 0;
}

Thank everyone too much!
I think you forgot to tell us the problem you're having :)
Topic archived. No new replies allowed.