The title may sound a bit confusing but basically what I'm trying to do is I have a file like this
int a = 0, j = 0;
int b = rand();
while(a != b) {
cin >> a;
++j;
}
So when b is found the amount of tries it took is stored in j and I want to use that to calculate and output the average amount of tries. The only way I could think of is to create a text file that is updated each time the user executes the file and after that reads from that text file to find the average of all times and output it but I couldn't get this to work because I'm not very good with file manipulation. If there is a better way to do this I would love to hear it and any help is greatly appreciated.
