问题:
编写一个程序实现功能:将字符串”Computer Secience”赋给一个字符数组,然后从第一个字母开始间隔的输出该串,用指针完成。
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1 #include <iostream>
2 using namespace std;
3
4 void main()
5 {
6 char str[100];
7 cin >> str;
8
9 int len = strlen(str);
10 char *p = str;
11 while(*p)
12 {
13 cout << *(p) << endl;
14 p = p+2;
15 }
16 }
测试:
abcdefgh
a
c
e
g
请按任意键继续. . .