GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::strlen(3) C++ Standard Libary std::strlen(3)

std::strlen - std::strlen


Defined in header <cstring>
std::size_t strlen( const char* str );


Returns the length of the given byte string, that is, the number of characters in a
character array whose first element is pointed to by str up to and not including the
first null character. The behavior is undefined if there is no null character in the
character array pointed to by str.


str - pointer to the null-terminated byte string to be examined


The length of the null-terminated string str.


std::size_t strlen(const char* start) {
// NB: no nullptr checking!
const char* end = start;
for( ; *end != '\0'; ++end)
;
return end - start;
}

// Run this code


#include <cstring>
#include <iostream>


int main()
{
const char str[] = "How many characters does this string contain?";


std::cout << "without null character: " << std::strlen(str) << '\n'
<< "with null character: " << sizeof str << '\n';
}


without null character: 45
with null character: 46


wcslen returns the length of a wide string
(function)
mblen returns the number of bytes in the next multibyte character
(function)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.