“cpp/string/char traits/find”的版本间的差异

来自cppreference.com
< cpp‎ | string‎ | char traits
(Translated from the English version using Google Translate)
 
 
(未显示4个用户的8个中间版本)
第1行: 第1行:
{{tr_note}}
 
 
{{cpp/string/char_traits/title|find}}
 
{{cpp/string/char_traits/title|find}}
 
{{cpp/string/char_traits/navbar}}
 
{{cpp/string/char_traits/navbar}}
{{ddcl list begin}}
+
{{ddcl{{|
{{ddcl list item |  
+
const *
const CharT* find( const CharT* p, std::size_t count, CharT a );
+
find( const * , std::size_t count, );
 
}}
 
}}
{{ddcl list end}}
 
  
Searches for character {{tt|a}} within the first {{tt|count}} characters within character string pointed to by {{tt|p}}.
+
{{|}} {{|count}} {{|}}
  
===。参数。===
+
{{|}} {{|}}
{{param list begin}}
+
{{param list item | p | pointer to a character string to search}}
+
{{param list item | count | the number of characters to analyze}}
+
{{param list item | a | the character to search for}}
+
{{param list end}}
+
  
===
+
=== ===
返回值。===
+
{{
A pointer to the first character of value {{tt|a}} withing the given character string.
+
|
 +
 +
 +
}}
  
=== 。例外。===
+
=== ===
{{tr| (无)。|(none)}}
+
{{| |}}
  
=== 复杂 性。===
+
===复杂 ===
{{tr| 线性.|Linear.}}
+
{{|线性
 +
 
 +
|}}

2024年3月9日 (六) 09:51的最后版本


static const char_type*
    find( const char_type* ptr, std::size_t count, const char_type& ch );
(C++17 起为 constexpr)

ptr 指向的字符序列的前 count 个字符中查找字符 ch

对字符特征的关于 X::find 的通用要求参考字符特征 (CharTraits)

[编辑] 参数

pre - 指向要查找的字符串的指针
count - 要分析的字符数量
ch - 要查找的字符

[编辑] 返回值

指向 [ptrptr + count) 所指定范围中首个比较等于 ch 的字符的指针,或在未找到时返回空指针。

[编辑] 复杂度

count 成线性。