update
Some checks failed
Deploy / deploy (push) Has been cancelled

This commit is contained in:
2026-01-06 22:33:03 +08:00
parent 3480b485d8
commit 7bda6b5d94
4 changed files with 936 additions and 671 deletions

257
src/shared/extensions/c.ts Normal file
View File

@@ -0,0 +1,257 @@
export const c = [
{
label: "printf",
detail: "格式化输出",
type: "function",
info: "标准输出函数,按格式打印,搭配 %d/%s 等占位符",
boost: 90,
apply: "printf();",
},
{
label: "scanf",
detail: "格式化输入",
type: "function",
info: "标准输入函数,按格式读取,用 & 取地址接收变量",
boost: 88,
apply: "scanf();",
},
{
label: "puts",
detail: "输出字符串",
type: "function",
info: "输出以 \\0 结尾的字符串并自动换行,比 printf 简洁",
boost: 84,
apply: "puts();",
},
{
label: "gets",
detail: "读取字符串",
type: "function",
info: "读取一行字符串到缓冲区(不安全,建议使用 fgets",
boost: 60,
apply: "gets();",
},
{
label: "fgets",
detail: "安全读行",
type: "function",
info: "从文件流读取一行到缓冲区,限制长度,避免溢出",
boost: 82,
apply: "fgets();",
},
{
label: "memset",
detail: "内存填充",
type: "function",
info: "按字节把内存填为指定值,常用于初始化数组或结构体",
boost: 80,
apply: "memset();",
},
{
label: "memcpy",
detail: "内存拷贝",
type: "function",
info: "从源地址复制指定字节到目标地址,避免重叠",
boost: 78,
apply: "memcpy();",
},
{
label: "strlen",
detail: "字符串长度",
type: "function",
info: "计算以 \\0 结尾的字符串长度(不含终止符)",
boost: 76,
apply: "strlen();",
},
{
label: "strcmp",
detail: "字符串比较",
type: "function",
info: "按字典序比较两个字符串,相等为 0小于返回负数",
boost: 74,
apply: "strcmp();",
},
{
label: "strcpy",
detail: "字符串拷贝",
type: "function",
info: "把源字符串复制到目标(含终止符),目标要有足够空间",
boost: 72,
apply: "strcpy();",
},
{
label: "int main",
detail: "程序入口",
type: "keyword",
info: "C 程序入口,通常返回 0 表示正常退出",
boost: 70,
},
{
label: "for",
detail: "循环语句",
type: "keyword",
info: "for (init; condition; step) 结构,用于固定次数循环",
boost: 68,
},
{
label: "while",
detail: "条件循环",
type: "keyword",
info: "while (condition) 条件循环,条件真则执行",
boost: 66,
},
{
label: "if",
detail: "条件判断",
type: "keyword",
info: "if (condition) 条件分支,可配 else/else if",
boost: 64,
},
{
label: "struct",
detail: "结构体定义",
type: "keyword",
info: "定义结构体,可组合不同类型的成员",
boost: 62,
},
{
label: "typedef",
detail: "类型别名",
type: "keyword",
info: "为已有类型起别名,提升可读性",
boost: 60,
},
{
label: "const",
detail: "只读限定",
type: "keyword",
info: "声明常量或只读指针,防止被修改",
boost: 58,
},
{
label: "return",
detail: "返回值",
type: "keyword",
info: "结束函数并返回值main 返回 0 表示成功",
boost: 56,
},
{
label: "break",
detail: "终止循环",
type: "keyword",
info: "立即退出最近的 for/while/do 循环体",
boost: 54,
},
{
label: "continue",
detail: "继续下一次循环",
type: "keyword",
info: "跳过当前循环余下语句,开始下一轮迭代",
boost: 52,
},
{
label: "do",
detail: "do-while 循环",
type: "keyword",
info: "do { ... } while(condition); 后置条件循环,至少执行一次",
boost: 50,
},
{
label: "else",
detail: "分支兜底",
type: "keyword",
info: "if/else if/else 结构中的兜底分支",
boost: 48,
},
{
label: "switch",
detail: "多分支选择",
type: "keyword",
info: "switch (expr) { case ... } 多分支选择结构,常配合 break",
boost: 46,
},
{
label: "case",
detail: "分支标签",
type: "keyword",
info: "switch 中的具体匹配分支,常在末尾使用 break",
boost: 44,
},
{
label: "default",
detail: "默认分支",
type: "keyword",
info: "switch 中未匹配任何 case 时执行的分支",
boost: 42,
},
{
label: "goto",
detail: "无条件跳转",
type: "keyword",
info: "跳转到指定标签位置,需谨慎使用以避免可读性问题",
boost: 40,
},
{
label: "sizeof",
detail: "求字节大小",
type: "keyword",
info: "返回类型或表达式所占字节数,编译期求值",
boost: 38,
},
{
label: "int",
detail: "整数类型",
type: "keyword",
info: "声明整型变量或返回值,通常占 4 字节",
boost: 36,
},
{
label: "char",
detail: "字符类型",
type: "keyword",
info: "声明字符或字节型变量,通常占 1 字节",
boost: 34,
},
{
label: "double",
detail: "双精度类型",
type: "keyword",
info: "声明双精度浮点变量,通常占 8 字节",
boost: 32,
},
{
label: "float",
detail: "单精度类型",
type: "keyword",
info: "声明单精度浮点变量,通常占 4 字节",
boost: 30,
},
{
label: "void",
detail: "空类型",
type: "keyword",
info: "表示无返回值或无类型指针void*",
boost: 28,
},
{
label: "unsigned",
detail: "无符号修饰",
type: "keyword",
info: "与整型/字符型组合表示无符号数,扩大正数范围",
boost: 26,
},
{
label: "long",
detail: "长整型修饰",
type: "keyword",
info: "与整型组合表示更大范围long/long long",
boost: 24,
},
{
label: "short",
detail: "短整型修饰",
type: "keyword",
info: "与整型组合表示较小范围的整数类型",
boost: 22,
},
]