If you just work with integers, I would suggest just making mod% 100 for simplicity:
int num =2341; cout << num%100;
41 will appear.
And if you only need zero output:
std::cout << std::setw(2) << std::setfill('0') << num%100 << std::endl;
source share