请教指点,看了好久都不知道问题出在什么地。
我写了一个程序
其中用到一个结构体
struct Node{
char * s;
Node * next;
string ordered_s;
};
之后我想构建一个list
函数如下
Node * buildup(Node * wordlist, char * word){
Node * temp = new Node;
temp->s = word;
cout << temp->s << " ";//
temp->ordered_s = ordering(word);
cout << temp->ordered_s << " " << endl;//
temp->next = wordlist;
wordlist = temp;
return wordlist;
}
是用wordlist的指针指向一个list,想在这个list之前插入一个word,但是我把它设置为char *类型,
temp->s = word;
cout << temp->s << " ";//
这个地方显示就不对。
但是下面我对这个word进行排序,显示却是正确的,其中ording的功能就类似char*p="apple",ording之后为aelpp (按字母数序排序)
这是为什么呢?
请指点。谢谢1