C / C++ 格式化工具
在线格式化和校验 C / C++ 代码,基于 clang-format 的 WebAssembly 版本,支持 Google、LLVM、Microsoft 等多种风格,直接在浏览器中完成处理。
浏览器本地处理
无需登录
基于 clang-format
语言适用于 C 和 C++ 代码
C++main.cpp
方言
风格
缩进
行宽
输入可编辑
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
输出C++ 有效27 行 · 595 B
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
class Person {
public:
Person(std::string name, int age) : name_(name), age_(age) {}
std::string getName() const { return name_; }
int getAge() const { return age_; }
bool operator<(const Person& other) const { return age_ < other.age_; }
private:
std::string name_;
int age_;
};
int main() {
std::vector<Person> people = {{"Alice", 30}, {"Bob", 25}, {"Carol", 35}};
std::sort(people.begin(), people.end());
for (const auto& p : people) {
std::cout << p.getName() << ": " << p.getAge() << std::endl;
}
return 0;
}
UTF-8 · 4 空格 · Google · clang-format本地处理 · 就绪
工具说明C / C++
简介
把缩进混乱或风格不统一的 C / C++ 代码重新整理成标准格式,底层使用 clang-format 的 WebAssembly 编译版本。支持 Google、LLVM、Chromium 等七种预设风格,以及自定义缩进宽度和行宽。所有处理都在浏览器本地完成,代码不会离开你的设备。
场景
格式化粘贴自文档或 AI 生成的 C/C++ 代码统一团队代码风格(Google/LLVM)整理缩进混乱的旧代码校验代码语法是否正确
使用步骤
123
粘贴或上传选择风格获取结果