c language: printf help
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 %%
精彩评论