-6
在下面的一段代碼中,我得到了下面提到的錯誤。請告訴我 爲什麼* P = T得到錯誤這裏這段代碼在字符串反轉中出現了什麼問題?
void reverse (char *p)
{
int length=strlen (p);
int c=0, i=length/2;
char *Temp=p+length-1, t;
while (c<length)
{
t=*Temp;
*Temp=*p
*p=t;
//Gives error as illegal, right operand has type char*
//Why is the error in the above line?
c++;
Temp--;
}
}
由於C++是在標籤中提到,這裏是如何使用STL扭轉的字符串:' std :: string reversed = string(str.rbegin(),str.rend());' – user2079303