10

数字のみで構成されていることが保証されている文字列 y が与えられました。stoi 関数を使用して int 変数に格納する前に、整数の境界を超えているかどうかを確認するにはどうすればよいですか?

string y = "2323298347293874928374927392374924"
int x = stoi(y); // The program gets aborted when I execute this as it exceeds the bounds
                 //   of int. How do I check the bounds before I store it?
4

3 に答える 3