我想使用 clang-format 将 C/C++ 文件转储到磁盘中。我现在正在使用这个命令:
clang-format file.c
重新格式化以下源代码片段:
int main() {
char name[50];
int marks, i, num;
printf("Enter number of students: ");
scanf("%d", &num);
return 0;
}
致:
int main() {
char name[50];
int marks, i, num;
printf("Enter number of students: ");
scanf("%d", &num);
return 0;
}
但是,我不知道如何将 clang-format 的输出转储到文件中,而不是将结果转储到终端中。谢谢。
您可以使用 -i 选项进行就地编辑。
clang-format -i test.c
clang-format file.c >output.cpp