void sort(char **string)函数参数什么意思??

来源:百度知道 编辑:UC知道 时间:2024/06/21 23:42:51
void sorted(char **str)函数参数什么意思??
悬赏分:20 - 解决时间:2009-6-11 19:17
void sorted(char **str)函数参数什么意思??
怎么使用? 怎么使用? 怎么使用? 怎么使用? 怎么使用? 怎么使用? 怎么使用? 怎么使用? 怎么使用? 怎么使用?

楼上不是已经回答得很清楚了吗
char** 就是一个指向char*的指针呀,下面代码是我写的一个示例, 不知道楼主能看得懂不
#include <iostream>
using namespace std;

void shorted(char** strs)
{
char* tempStr = new char[3];
if(strs[0] < strs[1])
{
memcpy(tempStr, strs[0], 3);
memcpy(strs[0], strs[1], 3);
memcpy(strs[1], tempStr, 3);
}
delete []tempStr;
}
int main()
{
char** strs;
strs = new char*[2];
strs[0] = new char[4];
strs[1] = new char[4];

memcpy(strs[0], "123", 3);
strs[0][3] = 0;
memcpy(strs[1], "567", 3);
strs[1][3] = 0;
shorted(strs);

cout<<strs[0]<<endl;
cout<<strs[1]<<endl;
delete strs;
return 0;
}

void sorted(char **str)等于void sorted(char *str[])

是个指针,指向一个char*.
也就是"指向指针的指针".