tags:

views:

41

answers:

2

i have program which prints all char from char_min to char_max here is code

#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
int main(){
    char c;
    c=CHAR_MIN;
     while(c!=CHAR_MAX){
          printf("d\n",c);
          c=c+1;

     }


return 0;



}

but it prints only all d why?ouput is like this

d
d
d
d
d
d
d
d
d
d

...

. . press any key to continue

+6  A: 
printf("d\n",c);     /// Means just print "d" (c is ignored)
printf("%d\n",c);     /// Means print the decimal value of varaible c
printf("%c\n",c);     /// Means print the charcter value of varaible c

Using "%d" will just print "0", "1", "2" etc.

Using "%c" will print the character values: "A", "B", "C" etc. Note, however, that the first 31 aren't printable.

James Curran
+2  A: 

replace

 printf("d\n",c);

with

printf("%c\n",c);
org.life.java
Have a look at http://www.codingunit.com/printf-format-specifiers-format-conversions-and-formatted-output
org.life.java