當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


C++ UINT_MAX用法及代碼示例

C++ UINT_MAX 宏常量

UINT_MAX 常量是 climits 頭文件中定義的宏常量,用於獲取 unsigned int 對象的最小值,它返回 unsigned int 對象可以存儲的最小值,即 4294967295(在 32 位編譯器上)。

注意:

  • 實際值取決於編譯器架構或庫實現。
  • 我們也可以使用<limits.h>頭文件而不是<climits>兩個庫中都定義了作為 UINT_MAX 常量的頭文件。

UINT_MAX 常量的語法:

    UINT_MAX

例:

    Constant call:
    cout << UINT_MAX;

    Output:
    4294967295

用於演示帶有 climits 標頭的 UINT_MAX 常量示例的 C++ 代碼

// C++ code to demonstrate example of 
// UINT_MAX constant with climits header
#include<iostream>
#include<climits>
using namespace std;

int main()
{
   //prinitng the value of UINT_MAX
    cout<<"UINT_MAX:"<<UINT_MAX<<endl;
    return 0;
}

輸出

UINT_MAX:4294967295

用limits.h頭文件演示UINT_MAX常量示例的C++代碼

// C++ code to demonstrate example of 
// UINT_MAX constant with <limits.h> header file
#include<iostream>
#include<limits.h>
using namespace std;

int main()
{
   //prinitng the value of UINT_MAX
    cout<<"UINT_MAX:"<<UINT_MAX<<endl;
    return 0;
}

輸出

UINT_MAX:4294967295


相關用法


注:本文由純淨天空篩選整理自 UINT_MAX constant with example in C++。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。