开发者

c language: printf help

开发者 https://www.devze.com 2022-12-24 16:33 出处:网络
here is my coding which gives me the error \'warning: unknown conversion type character 0x20 in format\'

here is my coding which gives me the error 'warning: unknown conversion type character 0x20 in format'

in开发者_如何学JAVAt subtotal;
long long a,b,c,d,e,f,g,h,i,j,k,l,m;
subtotal = (1*(a+c+e+g+i+k))+(3*(b+d+f+h+j+l));
printf(" = %d % 10 = %d; (10 - %d) % 10 = %lld\n", subtotal,subtotal%10,subtotal%10,m);

any idea why this is wrong?


Ignoring the fact you have a bunch of uninitialised variables, the % character is a special one in printf format strings - if you want a literal '%', you need '%%'.

printf(" = %d %% 10 = %d; (10 - %d) %% 10 = %lld\n", subtotal,subtotal%10,subtotal%10,m);


In printf you need a escape character to print % on the console you need to use %%

0

精彩评论

暂无评论...
验证码 换一张
取 消