警告fprintf

时间:2016-10-28 00:57:29

标签: c file warnings

我收到以下警告:

phonebook.c: In function ‘save_phonebook_xml’:
phonebook.c:93:2: warning: implicit declaration of function ‘fpritntf’ [-Wimplicit-function-declaration]
  fpritntf(file, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phonebook>\n");

以下是我的代码片段:

int save_phonebook_xml(const char *filename, phonebook_t *book){
int i, j;
FILE *file;
file = fopen(filename, "w");
if (file == NULL){
    printf("Failed to open file\n");
    return 1;
}
fpritntf(file, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phonebook>\n");
for(i = 0; i < book -> capacity; i++){
    human_t human = book -> humans[i];
    char tmp[768] = {0};
    strcat(tmp, human.name);
    strcat(tmp, " ");
    strcat(tmp, human.middle_name);
    strcat(tmp, " ");
    strcat(tmp, human.family_name);
    fprintf(file, "    <human name=\"%s\">\n", tmp);
    for(j = 0; j < human.num_of_phones; j++)
        fprintf(file, "        <phone>%s</phone>\n", human.phones[j]);
    fprintf(file, "    </human>\n");
}
fprintf(file, "</phonebook>");
fclose(file);
return 0;
}

我认为它因引号而引发,但我不知道如何正确处理它们。

1 个答案:

答案 0 :(得分:1)

似乎在第9行您输入了fpritnf而不是fprintf

相关问题