c - 用C写入文件

标签 c file file-writing

<分区>

下面有一段代码,我认为它非常简单,但由于某些原因无法正常工作,因为我收到错误 savedMap.c:20: warning: implicit declaration of function ‘fPrintf’。代码是:

#include "Structures.h"
#include "main.h"
#include <stdio.h>
#include <stdlib.h>

void populateFile() {
    printf("The method is being called");
    FILE *f = fopen("tempMap.txt", "w");
    if(f == NULL) {
        printf("The tempMap file could not be found, please ensure the file is present.");
    }

    const char *text = mapFirstLine;
    fPrintf(f, "Some text", text);
}

最佳答案

您可以在行下方替换 fPrintf(f, "Some text", text);

fprintf(f, "Some text", text); 

因为fPrintf()不是c中预定义的函数。

关于c - 用C写入文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36933690/

相关文章:

c - GCC:在不链接任何库的情况下编译应用程序

复制从文件中读取的字符串并将其存储在二维字符串数组中

java - Struts 2 下载文件为 0 字节

php - 如何在 codeigniter 中将数据写入 .txt 文件

c - 在c中解析char数组

c - Linux共享对象编译问题

c++ - 以二进制模式写入文件不起作用

java - 仅在发生错误或异常时而不使用 log4j 创建日志文件

Node.js:使用 fs.writeFileSync 写入系统文件

json - 使用 Golang 修改 JSON 文件