Pchar是什么类型,它与Pointer有什么关系?请大家帮帮忙,小鸟谢啦。

解决方案 »

  1.   

    PChar 是 字符型, 和 Pointer 没直接关系
      

  2.   

    PChar是为了兼容C中的字符串.是指向以#0为结束的字符串的指针.
    Pointer是指针.
      

  3.   

    PChar是以null结尾的字符型指针,Pointer是无类型的指针。string可以兼容pchar,如:
    var
      p:pchar;
      s:string;
    begin
      s := 'xyz';
      p := s;
      showmessage(p);
    end;
    单反过来就要进行转化。
      

  4.   

    PChar是以null结尾的字符型指针,Pointer是无类型的指针。string可以兼容pchar,反过来就要进行转化如:
    var
      p:pchar;
      s:string;
    begin
      s := 'xyz';
      p := pchar(s);//用pchar强类型转化
      showmessage(p);
    end;
      

  5.   

    同意solokey
    如果用messagebox函数的话,想要输出一串字符,就需要用Pchar强制转换,用法就如lq0711所说
      

  6.   

    to :lq0711(liqi0711) 
    我按早你的代码:
    [Warning] Unit1.pas(29): Unsafe type 'PChar'
    [Warning] Unit1.pas(40): Unsafe type 'p: PAnsiChar'
    [Error] Unit1.pas(40): Incompatible types: 'String' and 'PAnsiChar'
    请问这是为什么?
      

  7.   

    我也事了,没有错误...
    PChar指向Char类型的指针
    Pointer指向任意类型
      

  8.   

    Warning没所谓的PChar(XX)就是强制类型转换的Pointer相当于C的Void,无类型指针http://lysoft.7u7.net
      

  9.   

    POINTER是指向任何类型的指针
    PCHAR  是指向CHAR  型的指针
      

  10.   

    to :lq0711(liqi0711) 
    我按早你的代码:
    [Warning] Unit1.pas(29): Unsafe type 'PChar'
    [Warning] Unit1.pas(40): Unsafe type 'p: PAnsiChar'
    [Error] Unit1.pas(40): Incompatible types: 'String' and 'PAnsiChar'
    请问这是为什么?
    _______________________________
    这说明你是在Delphi7\8\9上面编程。很有可能是你在.NET上面,那个上面很多原来以PChar为参数类型的函数只接受string类型了,所以会有错。