输入一个字符串string,然后在string里面每个字母间加一个空格,请用指针完成。
来源:百度知道 编辑:UC知道 时间:2024/06/08 02:43:24
C++写的,在vc++6.0上运行的;
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{const int size=1000;
char str[size];
char *ch=str;
cout<<"please input the string "<<endl;
cin>>str;
for(int i=0;i<strlen(str)-1;i++)
cout<<*(ch+i)<<" ";
return 0;
}