比如char *buf;
结构:
typedef struct _myst
{
  int len;
  char data[255];
}myst;

解决方案 »

  1.   

    传递是什么意思?
    buf -> data? strcpy即可。
      

  2.   

    /*****************************感谢关注***************************/
    //////////////////////////////Creamdog////////////////////////////这样:
    myst *a = (myst*)buf;    //强制转换a->len;
    a->data;
    就可以访问了!
      

  3.   

    myst ms;
    int nMaxLen = 255 - 1;
    int nLen = strlen(buf);
    ms.len = (nLen > nMaxLen)? nMaxLen : nLen;
    strncpy(ms.data, buf, nMaxLen);
      

  4.   

    顺便问一下
    a->len 和 a.len 有什么区别吗?
      

  5.   

    myst ms;
    int nMaxLen = 255 - 1;
    int nLen = strlen(buf);
    ms.len = (nLen > nMaxLen)? nMaxLen : nLen;
    strncpy(ms.data, buf, nMaxLen);
      

  6.   

    啊,看错了,还有个typedef,没VC颜色分别嘛。
    应是:
     myst my;  //以后定义的struct最好用大写,如MYST。
     lstrcpy(my.data,buf); //顺便让你看看 . 跟 -> 的区别
      

  7.   

    定义结构大小的char *buf,再定义结构指针,强制转化一下即可
    char * buf=new char[sizeof(struct myst)];
    memset(buf,0,sizeof(struct myst));
    struct myst * ms=NULL;
    ms=(struct myst *)buf;
    delete buf;