Dave's Brain

Browse - programming tips - simple and fast strlen

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
What this info useful to you? You can donate to say thanks

Add a comment

Sign in to add a comment
Copyright © 2008-2012, 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.
Advertisements: