I want to use clang-format to dump C/C++ files into disk. I am using this command right now:
clang-format file.c
which reformat the following source code snippet:
int main() {
char name[50];
int marks, i, num;
printf("Enter number of students: ");
scanf("%d", &num);
return 0;
}
To:
int main() {
char name[50];
int marks, i, num;
printf("Enter number of students: ");
scanf("%d", &num);
return 0;
}
But, I do not know how can I dump the output of clang-format to a file instead of dumping the results in terminal. Thanks.
You can use Inplace edit with -i option.
clang-format -i test.c