成员如下:
  长度         数据类型
msg_id     8            unsigned integer
Msg_Length 1            unsigned integer
Msg   Msg_Length   string

解决方案 »

  1.   

    windows 本身的api使用的參數就有不少是不定長的結構, 一般加個 size 來表示實際的長度,
    象你的 Msg_Length 應該就可了
      

  2.   

    帮你顶一下吧,我记忆中好像要用socket传送record,那么它的里面string的长度一定要声明好,要不传送的时候会以length(string)=4的长度来定.
      

  3.   

    string可以是不定长的,长度由自动管理,用length(str)返回当前长度。不必定义Msg_Length。
      

  4.   

    string 這個類型會有問題得。。如果你定義了 > 1個string類型得member...在C++中 可以使用這樣得技巧 typedef tagTest = struct
    {
      int i;
      int j;
      char szValue[21];
      char szDynamic[1];
    }Test, *PTest;
    外面使用:
    PTest t = new Test;
    t.szDynamic = new char[100]; // szDynamic就指向100byte得一個控件樓主可以參考 使用 PChar,+Length..之類得..或者直接使用PChar...
      

  5.   

    我是这样定义的:
        TSMPP_RECSMS_tag = packed record
             Msg_id : Int64 ;
             Class_id : array[0..20-1] of Char;
             User_mobile : array[0..21-1] of Char;
             Msg_length : byte;
             Msg : array[0..Msg_length -1] of char;
            //Reserve: array[0..7] of Char; //保留
        end;
    可是编绎时会报错啊。Msg_length 是变量不行
      

  6.   

    定义成常量delphi初始化无法得到Msg_length的值,听一听大龙驹老师的解释
      

  7.   

    chinaandys(风流泪&VS&雨含笑) ,你说的定义成常量是不行的,因为Msg的长度是由Msg_Length来决定的
      

  8.   

    不是这样吗?const
       Msg_length=10;
    type
    TSMPP_RECSMS_tag = packed record
             Msg_id : Int64 ;
             Class_id : array[0..20-1] of Char;
             User_mobile : array[0..21-1] of Char;
             Msg_length : byte;
             Msg : array[0..Msg_length-1] of char;
            //Reserve: array[0..7] of Char; //保留
        end;
    //**********************************************
      

  9.   

    我在具体应用中遇到了这种情况,请问我该怎么办啊?
    正在做一个短信项目,情况是这样的:
    我在发送给sp一条短信后会收到返回的一条消息,消息体就如下面的结构所示:
      长度         数据类型
    msg_id     8            unsigned integer
    Msg_Length 1            unsigned integer
    Msg   Msg_Length   string
    请问我该怎么解决呢?谢谢!
      

  10.   

    用兩個變量進行代替
    一個 PChar類型
    一個為PChar所分配的長度。。注意使用的時候 必須分配內存 且指定分配的長度。。