By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,483 Members | 1,039 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,483 IT Pros & Developers. It's quick & easy.

write function ?

P: n/a
Hi,
I'm trying to understand a small cpp program which uses a function called
write.
An example of a line using this function is
write (hsocket,strclose,strlen(strclose)); where strclose is a string to
write, and hsocket is a int containing a socket handle.
The cpp program headers are
#include <iostream>
#include <string.h>
#include <sys/stat.h>
using namespace std;
and an included netfunc.h containing prototypes for various c sockets
functions in a netfunc.c program (but NOT write).

This write function must be the sockets write function ? But how does this
function compile correctly in this case ? It's a c function in a cpp file ?
Thanks
Tony
Feb 6 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Tony B wrote:
Hi,
I'm trying to understand a small cpp program which uses a function called
write.
An example of a line using this function is
write (hsocket,strclose,strlen(strclose)); where strclose is a string to
write, and hsocket is a int containing a socket handle.
The cpp program headers are
#include <iostream>
#include <string.h>
#include <sys/stat.h>
using namespace std;
and an included netfunc.h containing prototypes for various c sockets
functions in a netfunc.c program (but NOT write).

This write function must be the sockets write function ? But how does this
function compile correctly in this case ? It's a c function in a cpp file ?
Thanks
Tony

Likely it is just luck. On my system <iostreameventually include
<unistd.h>, which is where write is declared. Of course, the C++
standard doesn't guarantee that (write isn't part of the standard C++
library), and I very seriously doubt POSIX makes any such guarantee either.

--
Alan Johnson
Feb 6 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.