Dave's Brain

Browse - Programming Tips - What's a simple and fast strlen() implementation?

Date: 2009may26
Language: C/C++

Q.  What's a simple and fast strlen() implementation?

A.  From OpenBSD:

size_t strlen(const char *str) { const char *s; for (s = str; *s; ++s) ; return (s - str); }
glibc's is faster but its crazy complicated http://www.google.com/search?q=glibc+strlen

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.