Need to Make a couple of arrays

#include <iostream>
#include <fstream>
#include <string>

using namespace std;


bool openFiles (ifstream &fhInput);
void sortArray(int array[], int size);
void readFile(ifstream & fhInput, int arraynumbers[], int &arraySize);
const int SIZE = 12;
int sFirstName;
int sLastName;
int iaNames;
int main ()
{
ifstream fhIn;
bool bGoodOpen;

int i;

bGoodOpen = openFiles(fhIn);
if (bGoodOpen == false)
{
cout << "ERROR, file did not open properly, exiting... \n\n";
system ("pause");
return -1;
}
cout << readFile;
system ("pause");
return 0;
}


bool openFiles (ifstream &fhInput)
{
string sFileName;
cout << "File Name: ";
cin >> sFileName;
fhInput.open(sFileName.c_str()); // file input
if(!fhInput)
{
cout << "\nERROR, data file did not open sucessfully. \n";
system ("pause");
fhInput.clear ();
return false;
}
return true;
}

void readFile(ifstream & fhInput, int arraynumbers[], int &arraySize)
{

fhInput >> sFirstName;
while (!fhInput.eof())
{
fhInput >> sLastName;
for (int i = 0; i < 12; i++)
{
//make a new array to store lowest values
//make a new array to store highest values
//
fhInput >> arraynumbers [i];
}
//high (array)
//low (array)
fhInput >> sFirstName;
}
}

void sortArray(int array[], int size)
{
bool swap;
int temp;
do
{
swap = false;
for (int count = 0; count < (size - 1); count++)
{
if (array[count] > array[count + 1])
{
temp = array[count];
array[count] = array[count + 1];
array[count + 1] = temp;
swap = true;
}
}
} while (swap);
}



I need help making the arrays inside the function to output the highest and lowest values any help would be awesome thanks
this might help you get some replies..

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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include <iostream>
#include <fstream>
#include <string>

using namespace std;


bool openFiles (ifstream &fhInput);
void sortArray(int array[], int size);
void readFile(ifstream & fhInput, int arraynumbers[], int &arraySize);
const int SIZE = 12;
int sFirstName;
int sLastName;
int iaNames;
int main ()
{
ifstream fhIn;
bool bGoodOpen;

int i;

bGoodOpen = openFiles(fhIn);
if (bGoodOpen == false)
{
cout << "ERROR, file did not open properly, exiting... \n\n";
system ("pause");
return -1;
}
cout << readFile;
system ("pause");
return 0;
}


bool openFiles (ifstream &fhInput)
{
string sFileName;
cout << "File Name: ";
cin >> sFileName;
fhInput.open(sFileName.c_str()); // file input
if(!fhInput)
{
cout << "\nERROR, data file did not open sucessfully. \n";
system ("pause");
fhInput.clear ();
return false;
}
return true;
}

void readFile(ifstream & fhInput, int arraynumbers[], int &arraySize)
{

fhInput >> sFirstName;
while (!fhInput.eof())
{
fhInput >> sLastName;
for (int i = 0; i < 12; i++)
{
//make a new array to store lowest values
//make a new array to store highest values
//
fhInput >> arraynumbers [i];
}
//high (array)
//low (array)
fhInput >> sFirstName;
} 
}

void sortArray(int array[], int size)
{
bool swap;
int temp;
do
{
swap = false;
for (int count = 0; count < (size - 1); count++)
{
if (array[count] > array[count + 1])
{
temp = array[count];
array[count] = array[count + 1];
array[count + 1] = temp;
swap = true;
}
}
} while (swap);
}
although this would help even more =P
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

const int SIZE = 12;
int sFirstName;
int sLastName;
int iaNames;

bool openFiles (ifstream &fhInput)
{
    string sFileName;
    cout << "File Name: ";
    cin >> sFileName;
    fhInput.open(sFileName.c_str()); // file input
    if(!fhInput)
    {
        cout << "\nERROR, data file did not open sucessfully. \n";
        system ("pause");
        fhInput.clear ();
        return false;
    }
    return true;
}

void readFile(ifstream & fhInput, int arraynumbers[], int &arraySize)
{
    fhInput >> sFirstName;
    while (!fhInput.eof())
    {
        fhInput >> sLastName;
        for (int i = 0; i < 12; i++)
    {
    //make a new array to store lowest values
    //make a new array to store highest values
    //
    fhInput >> arraynumbers [i];
    }
        //high (array)
        //low (array)
        fhInput >> sFirstName;
    }
}

void sortArray(int array[], int size)
{
    bool swap;
    int temp;
    do
    {
        swap = false;
        for (int count = 0; count < (size - 1); count++)
        {
            if (array[count] > array[count + 1])
            {
                temp = array[count];
                array[count] = array[count + 1];
                array[count + 1] = temp;
                swap = true;
            }
        }
    } while (swap);
}

int main ()
{
    ifstream fhIn;
    bool bGoodOpen;

    int i;

    bGoodOpen = openFiles(fhIn);
    if (bGoodOpen == false)
    {
        cout << "ERROR, file did not open properly, exiting... \n\n";
        system ("pause");
        return -1;
    }
    cout << readFile;
    system ("pause");
    return 0;
}

Topic archived. No new replies allowed.