这是一个组合框的一个消息函数 我想实现的功能是 输入的字符串后,在我已经建好的链表里查找是否有这个字符串!
void CDictionaryDlg::OnEditchangeInputCombo() 
{
UpdateData(TRUE);
CString Value;
Value = m_input;
WORDNODE *result;
result = lookup(p, Value);

}
我得问题就是这个value是CString型 而我得链表里储存的都是char型 这两个怎么比较阿?
怎么把CString转化成char型阿!或者是怎么样实现这个功能!?
谢谢大家!查找函数的原型
WORDNODE *lookup(WORDNODE *listp, char *word)
{
for (; listp != NULL; listp = listp->next)
{
if (strcmp(word, listp->word)==0)
{
return listp;
}
} return NULL;
}这个是结构体
struct WORDNODE
{
char *word;
char *mean;  
char *anoun;
int rec;
WORDNODE *next;
};

解决方案 »

  1.   

    CString s1,
    char s[20];1)CString ---> char *;strcpy(s, s1.GetBuffer(0));2) char * --->CString
    s1.Format("%s", s);
      

  2.   

    Value.GetAt( index);与你的连表的字符比较也可以采用Value.Find(Str);
      

  3.   

    LPTSTR GetBuffer(
    int nMinBufLength ); 使用这个函数可以将CString类型的转化为char数组,而后你可以自己做了
      

  4.   

    CString 转 char *:
    CString str;
    int nLength=str.GetLength();
    char * sz=new char[nLength];
    sz=str.GetBuffer(0);