开发者

char printable program

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

#include <limits.h>
#include <开发者_JS百科;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


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.


replace

 printf("d\n",c);

with

printf("%c\n",c);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜