C++简单程序出错在那里?谢谢

来源:百度知道 编辑:UC知道 时间:2024/05/24 11:15:36
简单实现字符串倒序输出.怎么不能实现.看看错在哪里?谢谢了#include <iostream>
#include <math.h>
#include <string.h>
using namespace std;
int main()
{
int a=0,b=0;
char *p,str[20];
cout<<"shuchu"<<endl;
cin>>str;
a=strlen(str);
p=str;
for(b=0;b<a;b++)
{cout<<*p;
p--;}
return 0;
}
晕,去学完C++你就知道了,

int main()
{
int a=0,b=0;
char *p,str[20];
cout<<"shuchu"<<endl;
cin>>str;
a=strlen(str);
p=str+a; //最后一个字符的地址
for(b=0;b<=a;b++) //这样才能显示全
{
cout<<*p;
p--;
}
return 0;
}
//------------------------------
//其实就是首地址和末地址的获得然后循环操作而已

最上边的 #include <iostream>为什么没加
.h啊?
你的main函数还有返回值?返回给谁的?