char temp[1024] 
temp = "|流水号|日期|摘要|凭证种类|凭证号|借方发生额|贷方发生额|余额|柜员号|对方科目|"现在要把他拆开成各个字段,怎样实现,最好有代码!

解决方案 »

  1.   

    VB里面有个split,C好象没有,只好做循环了
      

  2.   

    笨方法:用CString 的 Find(); Left
    一个一个取。
      

  3.   

    c方法:
    char *p,*q;p = temp;
    while(*p){
         q=strtok(p,"|");
         if ( strlen(q) == 0  ){
             p = p + 1;
             continue;
          }
          puts(q);
         p = p + strlen(q) + 1;
    }
    //输出全部字段
      

  4.   

    char temp[1024] = "|流水号|日期|摘要|凭证种类|凭证号|借方发生额|贷方发生额|余额|柜员号|对方科目|";
    CString s = temp;
    CString d;
    int i;while (!s.IsEmpty())
    {
        i = s.Find("|");
        d = s.Left(i);
        MessageBox(d);
        s = s.Mid(i + 1);
    }d就是取出的各个字段。我已经试过了,你试一下。