Reading txt file,convert values to array, select certain values to sum

Write your question here.
How can I get C++ place values from a txt file to a 2X8 array with the [2][1] &[3][1] being text values and the rest numerical.
txt files looks like this
M F
3 3
4 4
2.2 2.7
3.2 2.75
3.6 3.7
3.1 2.8
3.5 3.0
So how I can get C++ to get the txt file arranged above.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <fstream>
#include <string>
double max, avg, sum;
using namespace std;
int input(ifstream){

int UAI;
}
int main(){
 ifstream file("UAI.txt");

 char output[35];
 if (file.is_open()) {
     string array[3][8];
int i;
for(i = 0; i < 3; ++i){
}
int j;
for( j=0;j<8;++j){
    file>>array[i][j];
     while (!file.eof()) {


    file >> output;
    cout<<output;


 }
}
file.close();
return 0;


I can get the file to read the txt file but i simply cannot get the values in the way I want them placed. Also if I may also ask of you to tell me how to select multiple specific values in an array, or just get the numbers from an array and the text values. Thank you so much
I am a beginner so this isn't propably the best way but I would do something like this:
1
2
    std::fstreamfile(UAI.txt)
    file >> num[0] >> num[1];


Last edited on
Topic archived. No new replies allowed.