Arcane Jill va escriure: > And yet, in an expression such as tolower(trim(s)), the second > validation is unnecessary. The input to tolower() /must/ be valid, > because it is the output of trim(). But on the other hand, tolower() > could be called with arbitrary input, so I can't skip the validation.
What is a "string" ? If you are using C as language, this is a particularly valid question, since the output can be larger than the input in general, so you will be resorted to add a maximum length parameter, or allowing realloc() which means that the strings are required to be malloc'ed on first place. As a result, your strings are likely to be some stuctures. Then, it is pretty easy to add some s_valid flag, and you are done. Antoine