Skip to content

Instantly share code, notes, and snippets.

@jlyu
Created October 9, 2013 08:19
Show Gist options
  • Save jlyu/6897965 to your computer and use it in GitHub Desktop.
Save jlyu/6897965 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
bool updateProcess(int pct)
{
cout << pct << "% complete...\n";
return (true);
}
typedef bool (*FuncPtrBoolInt)(int);
void longOperation(FuncPtrBoolInt update)
{
long upperBound = 10000000;
for(long i=0; i<upperBound; i++)
{
if (i*100 % upperBound == 0)
{
update(i*100 / upperBound);
}
}
}
int main()
{
longOperation(updateProcess);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment