dydx
dydx

Reputation: 35

c language: printf help

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?

Upvotes: 2

Views: 1977

Answers (2)

Naveen
Naveen

Reputation: 73443

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

Upvotes: 3

anon
anon

Reputation:

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

Upvotes: 6

Related Questions