برای اینکار از متد rfind از کلاس std::string استفاده کن.
std::string str = "test.txt"; auto result = str.rfind("."); //output > .txt