
今天学习了数组,然后自己想通过数组来实现的打印 hello world,大概思路是这样的 #include <stdio.h> int main() { char ch[10]={h,e,l,l,o,w,o,r,l,d}; printf("%s%s%s%s%s %s%s%s%s%s\n",ch[0],ch[1],ch[2],ch[3],ch[4],ch[5],ch[6],ch[7],ch[8],ch[9]); return 0; }
然后显示里面的每个字母需要声明。求大神指导。
1 VVVVVEX 2018 年 8 月 7 日 你是在考验大家的阅读理解么? |
2 bombless 2018 年 8 月 7 日 via Android 需要声明还行。你需要把%s 都换成%c |
3 gbin 2018 年 8 月 7 日 via Android 可以用循环嘛。 建议: 1.入门的时候可以看一些优秀的视频,实在的去 icourse163.org 上找找; 2. 入门以后慢慢啃经典书,比如《 C++ Primer 》,有中文版。 不要网上谁的资料都拿来用,特别是博客,博主写博客大部分是自己当笔记用,很少想要去教书育人。 |
4 sikariba 2018 年 8 月 7 日 没有用单引号把字母包起来? |
5 bombless 2018 年 8 月 7 日 via Android 哈,是,你需要字符字面量,'h'之类的 |
9 V3EX17 2018 年 8 月 7 日 via Android %s 改成%c,且不需要那么多,改成循环打印出来,类似于(int i=0;i<10;i++){printf("%c",ch[i]);} |