1. ## estimating time remaining

I am working on a c++ program, It basically copys file into another file. I current have the program outputting how many mb it has done and the pecentage of the operation (i.e 5mb out of 50mb 10% complete)

i would also like to add an estimated remaining time and elapsed time if possible. Therefore the output would like like:-

5MB out of 50MB 10% Complete Estimated time remaining 2:21 mins. Total time elapsed 1 min

Any thoughts off how i can do this, please let me know

2. The sneaky way: just use a random number generator to make up a time.

3. set a timer for 10 seconds.
after 10 seconds take the percent done. lets say its 10%

you have 9 * 10 seconds left.
divide by 60 to get minutes
% 60 to get seconds

now you just gota find out how to use timers

4. PercentDone is a real number (0.0 -> 1.0) telling how much of the file is complete (0.0 = 0%, 1.0 = 100%).
SecondsTaken contains how many seconds have passed so far.
Code:
```long int GetTimeLeft(double PercentDone, long int SecondsTaken)
{
//Prevent division by 0
if(PercentDone == 0.0) return 0;

//Calculate the time remaining
return (long int)(((double)SecondsTaken / PercentDone) - (double)SecondsTaken + 0.99999);
}```
EDIT: The last 0.99999 is for rounding perfection (skip it if you like, who cares for a +/- second )

5. Is there any function that returns the length of a file?
Example:
Code:
```int main(){

ifstream inFile("File.txt");

cout << "The size of the file is " << inFile.size();

return 0;
}```
This function(if exists) could solve all the problem...

6. Code:
```long int GetFileLength(const char* FileName)
{
long int Size;

ReadFile.open(FileName, ios::in | ios::nocreate | ios::binary);
{
return -1;
}