problem with write() function

hello,

i use the function :
1
2
3
4
5
6
string msg(void)
{
    stringstream c (stringstream::in | stringstream::out);
    //read from file
    return c.str();
}


and then in the main function i need to use the write() function:

1
2
3
4
5
6
7
8
int main(void)
{
    //code
    string a;
    a = msg();
    write(sock, a, length(a)); 
    //code    
}


the problem is on the 3rd parameter of write() function, where i receive the message-error:

`length' was not declared in this scope


also, i tried the strlen() function and i receive the error message below :

cannot convert `std::string' to `const char*' for argument `1' to `size_t strlen(const char*)'


Any help, please.

Thank you .
Last edited on
I think you may need this:
 
write(sock, a.c_str(), a.length());
Yes, it is working ! Thank you very much GALIK .
Topic archived. No new replies allowed.