C 文字中的分界符部和单位

Delimiter tens and units in c++ literals

本文关键字:单位 分界符部 文字      更新时间:2023-10-16

在java中我可以做:

int i = 1_200_200;

我如何在C 中做同样的事情?我的意思是我应该使用什么而不是下划线?

以来C 14您可以使用单个引号(')来提高可读性,例如。

int i = 1'200'200;

可选的单报价(')可以在数字之间插入 分隔器。它们被编译器忽略。

在C 中您可以使用普通报价。例如

#include <iostream>
int main() 
{
    int x = 1'234'567;
    std::cout << "x = " << x << std::endl;
    return 0;
}

在c中不存在这样的功能。