【问题标题】:How can I output clang-format results to a file?如何将 clang 格式的结果输出到文件?
【发布时间】:2021-12-28 06:17:02
【问题描述】:

我想使用 clang-format 将 C/C++ 文件转储到磁盘中。我现在正在使用这个命令:

clang-format file.c

重新格式化以下源代码sn-p:

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 的输出转储到文件中,而不是将结果转储到终端中。谢谢。

【问题讨论】:

    标签: clang clang-format


    【解决方案1】:

    您可以使用带有 -i 选项的就地编辑。

    clang-format -i test.c
    

    【讨论】:

    • 谢谢。这里的inplace是什么意思?
    • 替换在同一个文件中。
    猜你喜欢
    • 2011-01-08
    • 2020-06-15
    • 2021-06-25
    • 2023-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-12
    相关资源
    最近更新 更多