A little help with file header

I was trying to make a header file that will convert strings to lowercase, uppercase, but I'm having a problem in capitalizing every word in a string.
These codes work on the main() but I can't get it to work on a function or header. The problem is with "strlen". Is there way to improvised the code or do I have to place this in the main()? I want to place all the convertion functions in the same header if possible.

1
2
3
4
5
6
7
8
9
10
11
inline std::string& strcps(std::string& z)
{
    z[0] = toupper(z[0]);
    int d = strlen(z);
    for (int i = 1; i < d; ++i)
    {
        if(z[i] == ' ') // If a space
        z[i+1] = toupper(z[i+1]);
    }
    return z
}


I need at least a hint to get around this.
Thanks in advance.
Cheers!
strlen(z); stlen works only on C-strings.

You have and std::string, why not use it member function .length() or .size() ?
int d = z.size();

Also your code will not work properly on string like:
eidos (greek term meaning "form," "essence")
Sorry, I'm trying to learn C++ from a book, and that's about the only code that's in there. It's a beginner's book though.
It's working now. Many thanks.
Topic archived. No new replies allowed.