在C语言中,如果你想向一个文件追加内容,你可以使用`fopen`函数以追加模式("a")打开文件。如果文件不存在,它将被创建。如果文件已经存在,新的内容将被追加到文件的末尾。
以下是一个简单的例子,演示了如何向文件追加内容:
```c
include
int main() {
FILE file;
const char filename = "example.txt";
const char text = "This is some text to append to the file.n";
// 以追加模式打开文件
file = fopen(filename, "a");
if (file == NULL) {
perror("Error opening file");
return 1;