Sorry if explanation is bad, English is not my first language.
I'm needed to make code to read file and print code from file.
I'm new to coding but know the basics.
I've just included the code that written up to this point.
When program is run nothing shows up. Not even "Hi" at begin of code.
When I remove parts of code "Hi" shows up. It seem to cause problem when opening of file first starts in function.
If this is wrong place to post I apologize, anymore information needed can be provided.
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
void ReadData (int accts[], double balance [], int size);
void SortData (int accts[], double balance[]);
int ReadNumber ();
int Search (int userNum, int accts[], double balance []);
int main()
{
cout << "Hi";
//Declare variables
const int ARRAY_SIZE = 20;
int accts[ARRAY_SIZE];
double balance[ARRAY_SIZE];
int count;
int userNum;
//Call functions
ReadData (accts, balance, ARRAY_SIZE);
//Printing the Arrays
for(count = 0; count < 20; count++)
cout << accts[count] << " " << balance[count];
return 0;
}
void ReadData (int accts[], double balance [], int size)
{
ifstream infile; //input
int count;
//Opening the file
infile.open("demo.txt");
cout << "Opening file...\n";
if (!infile)
cout << "File open failure!\n";
//Reading the file
for(count = 0; count < size; count++)
{
infile >> accts[count];
infile >> balance[count];
}
//Closing the file
cout << "Closing file...\n";
infile.close();
return;
}