printf - How do I print this in C? -
hi i'm relatively new programming please bear me.
i create programme takes input bcdefghijklmnopqrstuvwxy
, outputs
else if (c == 'x') ++nx;
where x letter of input, , output repeated each letter of input.
this have written far:
#include <stdio.h> main() { int c; while((c = getchar()) != eof) { printf("else if (c == '%d')\n", c); printf("\t++n%d;\n", c); } homecoming 0; }
instead of returning output want, output is
else if (c == '98') ++n98; else if (c == '99') ++n99; else if (c == '100') ++n100; else if (c == '101') ++n101; else if (c == '102') ++n102; ...
why c
not working variable?
thanks much help!
when writing in c , printing string pointed format stdout you'll need create sure you're using right format specifiers. ensure argument formatted correctly , inserted resulting string expect.
in case, need utilize %c
. however, have %d
currently, equivalent %i
integers. can google more on format specifiers larn more other options well.
here's interesting read on subject:
http://www.codingunit.com/printf-format-specifiers-format-conversions-and-formatted-output
c printf getchar
No comments:
Post a Comment