help me to read data

I don't know where, but seems my code is wrong.
this is my input:
6 92 86 78 93 22 56
4 90 83 85 58

the first number indicates the total set of data

and also what if I have a lot set of data ?
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
 
#include <iostream>
#include <stdlib.h>
#include <conio.h>
#include <fstream>
#include<iomanip>
using namespace std;
#define SIZE 50
void main()
{
	void read_data(double x[], int &n,ifstream &);
	double a[SIZE], b[SIZE]
        int addressN=0;
	ifstream input;
	input.open("data.txt", ios::in);
	if (input.fail())
	{
		cerr<<"Input file could not be opened!" <<endl;
		exit (-1);
	}

	while (!input.eof())
	{
		read_data(a, b, input);
		
	}
	input.close();
}
{

	ofstream outdata;
	outdata.open("output.txt", ios::out);
	if (outdata.fail())
	{
		cerr << "Output file could not be opened! " << endl;
		exit(-1);
	}
	outdata << "\nThere are number in data set number";<<addressN;
	outdata << setiosflags(ios::fixed) << setprecision(4);
	
}
void read_data(double p[],double q[],ifstream &data )
{
	int a;
	for (a=0; a < 50 ; a++)
	{
		data >> p[a];
	}
	int a;
	for (a=0 ; a< 50 ; a++)
	{
		data >> q[a];
	
	}
	
	}
Last edited on
The first error that the compiler shall issue is that variables a and b were not declared.

while (!input.eof())
{
read_data(a, b, input);
Hi, please use code tags. It has the <> symbol.

Aceix.
Topic archived. No new replies allowed.