以下交换字符串的程序到底哪里错了
帮我看看以下交换字符串的程序到底哪里错了,编译通过,运行时出现错误.
#include<iostream.h>
#include<string.h>
int stringswp(char * i,char * j){
char temp[100];
strcpy(temp,i);
strcpy(i,j);//好像这句出的错
strcpy(j,temp);
return 0;
}
int main(){
char *p="how are you";
char *q="how you";
stringswp(p,q);
while(*p!='\0'){
cout<<*p;
p++;
}
cout<<endl;
while(*q!='\0'){
cout<<*q;
q++;
}
return 0;
}