Hello all, I have written the following program which is running perfect but what I want is whenever I make any changes in my array I want it to be changed accordingly in my file.
my text file looks like this: 1 2 3 4 5
Any help is really appreciated.
#include <iostream>
#include <fstream>
using namespace std;
int change(int SEAT[5])
{
for (int i = 0; i <5; i++)
{
SEAT[i] = 1;
}
}
int main ()
{
ifstream input("test.txt");
int seat[5];
for (int i = 0; i <5; i++)
{
input >> seat[i];
}
for (int i = 0; i <5; i++)
{
cout << seat[i] << " ";
}
change(seat);
cout << "\nNew array is: \n";
for (int i = 0; i <5; i++)
{
cout << seat[i] << " ";
}
input.close();
return 0;
}