Sorry if this is a stupid question, but...
The order of Complexity of this code is O(n):
char buf[] = "hello world";
size_t length = strlen(buf);
for(size_t i = 0; i < length; i++)
{
//do stuff
}
and this code is O(n^2):
char buf[] = "hello world";
for(size_t i = 0; i < strlen(buf); i++)
{
//do stuff
}
because strlen is O(n).
But who says that strlen is O(n), is it defined in the standard, does it have to be O(n)?
How can I know for sure what the Order of Complexity of any standard function is going to be?