C,格式为[-Wformat =]错误的未知转换类型字符0x20

时间:2016-01-20 00:58:18

标签: c printf

printf("\nThe largest dog is %c with a weight of %.2 kg\n", largetype, largest);
fprintf(outfile,"\The largest dog is %c with a weight of %.2f kg\n", largetype , largest);
printf("\nThe smallest dog is %c with a weight of %.2f kg\n", smalltype , smallest);
fprintf(outfile,"\nThe smallest dog is %c with a weight of %.2f kg\n", smalltype , smallest);

你好,

所以我的C程序没有编译,它显示我这个错误,

未知转换类型字符0x20,格式为[-Wformat =]

前两行。 有谁知道如何处理这个错误?

1 个答案:

答案 0 :(得分:4)

在你的第一行

printf("\nThe largest dog is %c with a weight of %.2 kg\n", largetype, largest);

您正在使用%.2,但是您没有指定类型,这是什么导致转换错误。\ n \ n您应该使用%.2f,就像下面的行一样。

printf("\nThe largest dog is %c with a weight of %.2f kg\n", largetype, largest);