Purifying flames Purifying flames - 1 year ago 135
C Question

Warning fprintf

I'm getting the following warning:

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");

Here is the snippet of my code:

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>");
return 0;

I think it raises because of quotes, but i don't know how to deal with them correctly.

Answer Source

It seems that on line 9 you have typed fpritnf instead of fprintf.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download