Im having trouble outputting my array file, im using a separate function instead of having it in the main function,is there anything that im doing wrong??
cout << " Charge Account Validation created by Cedric Shumate"<< endl;
cout << "Enter a number in the account or 9999 to quit: ";
int number;
cin >> number;
while (number < 1 || number >9999)
{
cout << "Error: Enter a number that is in the account: ";
cin >> number;
}
return 0;
}
void arrFile()
{
const int ACCOUNT_SIZE = 10;
int account[ACCOUNT_SIZE];
int count = 0;
ifstream inputArrayfile;
inputArrayfile.open("charges.txt");
while (count < ACCOUNT_SIZE && inputArrayfile >> account[count])
count++;
I don't know what is supposed to be the output here?
Function main() simply requests an integer from 1 to 9999.
Then the program ends.
You declare a function, void displayFile(int); but the body of the function has not been defined. In any case this function is never called.
You've also defined a function void arrFile()which is never called.
If it was called, it would try to read some values (input) from a file, into the local array int account[ACCOUNT_SIZE];, though that array goes out of scope when the function ends, so it's not particularly useful as it stands.
Overall, this looks like a work in progress. There may be mistakes in the code, but the biggest problem is that it is simply incomplete.
Function main() needs to do more, such as calling one or both of your functions for example.
ok calling the function in main is where im having the problem
i use arrFile() in main but its telling me there is an error
error C2660 function does not take 1 arguements
what is the problem here??
void arrFile();
void displayFile(int);
void sortFile(const int [], int);
void displaySortfile(const int [], int);
int searchFile(const int [], int, int);
int main()
{
cout << " Charge Account Validation created by Cedric Shumate"<< endl;
arrFile();
cout << "Enter a number in the account or 9999 to quit: ";
int number;
cin >> number;
while (number < 1 || number >9999)
{
cout << "Error: Enter a number that is in the account: ";
cin >> number;
}
return 0;
}
void arrFile()
{
const int ACCOUNT_SIZE = 10;
int account[ACCOUNT_SIZE];
int count = 0;
ifstream inputArrayfile;
inputArrayfile.open("charges.txt");
while (count < ACCOUNT_SIZE && inputArrayfile >> account[count])
count++;
inputArrayfile.close();
}
void displayFile(const int array[], int account)
{
cout << "Original Order";
for (int count = 0; count < account; count++)
cout << array[count] << " ";
cout << endl;