美文网首页
AnsiLastChar - C++ Builder

AnsiLastChar - C++ Builder

作者: 玄坴 | 来源:发表于2021-08-19 08:05 被阅读0次

C++ Builder 参考手册System::SysutilsAnsiLastChar


返回指向字符串当中最后一个字符的指针

头文件:#include <System.SysUtils.hpp>
命名空间:System::Sysutils
函数原型:

System::WideChar * __fastcall AnsiLastChar(const System::UnicodeString S);

参数:

  • S:字符串

返回值:

  • 如果 S 为空字符串,返回 NULL;
  • 如果 S 不是空字符串,返回指向 S 里面最后一个字符的指针;
    • 由 2 个 char16_t 组成的代理对 (4 个字节的字符) 可以正确的返回,请参考 UnicodeString 和 UTF16 编码,这时候返回的就是倒数第 2 个 char16_t 而不是最后一个 char16_t;
    • 返回的指针直接指向 S 占用的内存,如果 S 是一个临时对象,返回的指针指向的内存被释放,可能会被其他程序占用而无法得到正确的值;

相关:

  • System::Sysutils::AnsiStrLastChar
  • System::Sysutils::AnsiPos
  • System::Sysutils::AnsiStrPos
  • System::Sysutils::AnsiStrScan
  • System::Sysutils::AnsiStrRScan
  • System::Sysutils::CharToElementIndex
  • System::Sysutils::CharToElementLen
  • System::Sysutils::ElementToCharIndex
  • System::Sysutils::ElementToCharLen
  • System::Sysutils
  • <cstdlib>

C++ Builder 参考手册System::SysutilsAnsiLastChar

相关文章

网友评论

      本文标题:AnsiLastChar - C++ Builder

      本文链接:https://www.haomeiwen.com/subject/xupdahtx.html