Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 当我需要字母字符时,程序生成数字_C_Loops_Nested - Fatal编程技术网

C 当我需要字母字符时,程序生成数字

C 当我需要字母字符时,程序生成数字,c,loops,nested,C,Loops,Nested,我的代码: #include <stdio.h> int main() { char x, y; for(x='a';x<='c';++x) { for(y='a';y<='c';++y) { printf("%c %d\r\n",x,y); } } return(0); } 我想要: a a b a c b a b b。。。等 我得到: a 97 a 98 a 99 b 97 b 98。。。等 我缺少什么?这是我

我的代码:

#include <stdio.h>
int main()
{
  char x, y;
  for(x='a';x<='c';++x)
  {
    for(y='a';y<='c';++y)
    {
      printf("%c %d\r\n",x,y);
    }
  }
  return(0);
}
我想要: a a b a c b a b b。。。等

我得到: a 97 a 98 a 99 b 97 b 98。。。等


我缺少什么?

这是我的第一个程序和第一次编译。感谢您的回复。 我将一行更改为:

printf("%c %d\r\n",x,y);
致:


我有很多东西要学://

你有一个%d在里面printf@PiRocks不会的。char值将经历默认参数升级为int。事实上,%d和%c都需要int类型的参数。@PiRocks-不,不会。在对printf的调用中,由于省略号。。。在printf原型的末尾。
printf("%c %c\r\n",x,y);