C++ maximum non negative int

前端 未结 5 1442
既然无缘
既然无缘 2021-01-28 12:24

Is the following going to work as expected on all platforms, sizes of int, etc? Or is there a more accepted way of doing it? (I made the following up.)

#define M         


        
5条回答
  •  鱼传尺愫
    2021-01-28 12:31

    There is a standard way to this:

    #include 
    #include 
    
    cout << numeric_limits::max();
    

    Being standard, this is guaranteed to be portable across all platforms.

提交回复
热议问题