本文共整理了C/C++关键字,其中C关键字32个,C++关键字97个。为了方便使用分别使用三种格式梳理。
共收录32个关键字。
关键字 说明
auto 声明自动变量
short 声明短整型变量或函数
int 声明整型变量或函数
long 声明长整型变量或函数
float 声明浮点型变量或函数
double 声明双精度变量或函数
char 声明字符型变量或函数
struct 声明结构体变量或函数
union 声明共用数据类型
enum 声明枚举类型
typedef 用以给数据类型取别名
const 声明只读变量
unsigned 声明无符号类型变量或函数
signed 声明有符号类型变量或函数
extern 声明变量是在其他文件正声明
register 声明寄存器变量
static 声明静态变量
volatile 说明变量在程序执行中可被隐含地改变
void 声明函数无返回值或无参数,声明无类型指针
if 条件语句
else 条件语句否定分支(与 if 连用)
switch 用于开关语句
case 开关语句分支
for 一种循环语句
do 循环语句的循环体
while 循环语句的循环条件
goto 无条件跳转语句
continue 结束当前循环,开始下一轮循环
break 跳出当前循环
default 开关语句中的“其他”分支
sizeof 计算数据类型长度
return 子程序返回语句(可以带参数,也可不带参数)循环条件
"void","char","int","float","double","short","long","signed","unsigned","struct","union","enum","typedef","sizeof","auto","static","register","extern","const","volatile","return","continue","break","goto","if","else","switch","case","default","for","do","while"
"void",
"char",
"int",
"float",
"double",
"short",
"long",
"signed",
"unsigned",
"struct",
"union",
"enum",
"typedef",
"sizeof",
"auto",
"static",
"register",
"extern",
"const",
"volatile",
"return",
"continue",
"break",
"goto",
"if",
"else",
"switch",
"case",
"default",
"for",
"do",
"while",
void,
char,
int,
float,
double,
short,
long,
signed,
unsigned,
struct,
union,
enum,
typedef,
sizeof,
auto,
static,
register,
extern,
const,
volatile,
return,
continue,
break,
goto,
if,
else,
switch,
case,
default,
for,
do,
while,
共收录97个C++关键字,
来源: https://www.apiref.com/cpp-zh/cpp/keywords.html
"alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","bool","break","case","catch","char","char8_t","char16_t","char32_t","class","compl","concept","const","consteval","constexpr","constinit","const_cast","continue","co_await","co_return","co_yield","decltype","default","delete","do","double","dynamic_cast","else","enum","explicit","export","extern","false","float","for","friend","goto","if","inline","int","long","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","private","protected","public","reflexpr","register","reinterpret_cast","requires","return","short","signed","sizeof","static","static_assert","static_cast","struct","switch","synchronized","template","this","thread_local","throw","true","try","typedef","typeid","typename","union","unsigned","using","virtual","void","volatile","wchar_t","while","xor","xor_eq",
"alignas",
"alignof",
"and",
"and_eq",
"asm",
"atomic_cancel",
"atomic_commit",
"atomic_noexcept",
"auto",
"bitand",
"bitor",
"bool",
"break",
"case",
"catch",
"char",
"char8_t",
"char16_t",
"char32_t",
"class",
"compl",
"concept",
"const",
"consteval",
"constexpr",
"constinit",
"const_cast",
"continue",
"co_await",
"co_return",
"co_yield",
"decltype",
"default",
"delete",
"do",
"double",
"dynamic_cast",
"else",
"enum",
"explicit",
"export",
"extern",
"false",
"float",
"for",
"friend",
"goto",
"if",
"inline",
"int",
"long",
"mutable",
"namespace",
"new",
"noexcept",
"not",
"not_eq",
"nullptr",
"operator",
"or",
"or_eq",
"private",
"protected",
"public",
"reflexpr",
"register",
"reinterpret_cast",
"requires",
"return",
"short",
"signed",
"sizeof",
"static",
"static_assert",
"static_cast",
"struct",
"switch",
"synchronized",
"template",
"this",
"thread_local",
"throw",
"true",
"try",
"typedef",
"typeid",
"typename",
"union",
"unsigned",
"using",
"virtual",
"void",
"volatile",
"wchar_t",
"while",
"xor",
"xor_eq",
alignas,
alignof,
and,
and_eq,
asm,
atomic_cancel,
atomic_commit,
atomic_noexcept,
auto,
bitand,
bitor,
bool,
break,
case,
catch,
char,
char8_t,
char16_t,
char32_t,
class,
compl,
concept,
const,
consteval,
constexpr,
constinit,
const_cast,
continue,
co_await,
co_return,
co_yield,
decltype,
default,
delete,
do,
double,
dynamic_cast,
else,
enum,
explicit,
export,
extern,
false,
float,
for,
friend,
goto,
if,
inline,
int,
long,
mutable,
namespace,
new,
noexcept,
not,
not_eq,
nullptr,
operator,
or,
or_eq,
private,
protected,
public,
reflexpr,
register,
reinterpret_cast,
requires,
return,
short,
signed,
sizeof,
static,
static_assert,
static_cast,
struct,
switch,
synchronized,
template,
this,
thread_local,
throw,
true,
try,
typedef,
typeid,
typename,
union,
unsigned,
using,
virtual,
void,
volatile,
wchar_t,
while,
xor,
xor_eq,
"alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","bitand","bitor","bool","catch","char8_t","char16_t","char32_t","class","compl","concept","consteval","constexpr","constinit","const_cast","co_await","co_return","co_yield","decltype","delete","dynamic_cast","explicit","export","false","friend","inline","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","private","protected","public","reflexpr","reinterpret_cast","requires","static_assert","static_cast","synchronized","template","this","thread_local","throw","true","try","typeid","typename","using","virtual","wchar_t","xor",
"alignas",
"alignof",
"and",
"and_eq",
"asm",
"atomic_cancel",
"atomic_commit",
"atomic_noexcept",
"bitand",
"bitor",
"bool",
"catch",
"char8_t",
"char16_t",
"char32_t",
"class",
"compl",
"concept",
"consteval",
"constexpr",
"constinit",
"const_cast",
"co_await",
"co_return",
"co_yield",
"decltype",
"delete",
"dynamic_cast",
"explicit",
"export",
"false",
"friend",
"inline",
"mutable",
"namespace",
"new",
"noexcept",
"not",
"not_eq",
"nullptr",
"operator",
"or",
"or_eq",
"private",
"protected",
"public",
"reflexpr",
"reinterpret_cast",
"requires",
"static_assert",
"static_cast",
"synchronized",
"template",
"this",
"thread_local",
"throw",
"true",
"try",
"typeid",
"typename",
"using",
"virtual",
"wchar_t",
"xor",
alignas,
alignof,
and,
and_eq,
asm,
atomic_cancel,
atomic_commit,
atomic_noexcept,
bitand,
bitor,
bool,
catch,
char8_t,
char16_t,
char32_t,
class,
compl,
concept,
consteval,
constexpr,
constinit,
const_cast,
co_await,
co_return,
co_yield,
decltype,
delete,
dynamic_cast,
explicit,
export,
false,
friend,
inline,
mutable,
namespace,
new,
noexcept,
not,
not_eq,
nullptr,
operator,
or,
or_eq,
private,
protected,
public,
reflexpr,
reinterpret_cast,
requires,
static_assert,
static_cast,
synchronized,
template,
this,
thread_local,
throw,
true,
try,
typeid,
typename,
using,
virtual,
wchar_t,
xor,