tags:

views:

302

answers:

2

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

int 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?

+5  A: 

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);
anon
ahh, thank you very much!
dydx
+2  A: 

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

Naveen