Function Write()

This is a discussion on Function Write() within the C Programming forums, part of the General Programming Boards category; Hi,
can anyone tell me how to get the retun value of the function:
Code:
write(int fildes, const void *buf, ...

write should return a positive (or zero) value representing the number of bytes written for when it is successful, and anything negative returned is an error, yes. The value in errno would indicate WHAT went wrong.

but how would I find out the number of bytes it has written or if it returns an error?

Erm, if it's negative, then it (most likely) didn't write any bytes. But what I was trying to say is that you are mixing functions that are part of different API's - write is not using the same type of information as a "handle" or "file descriptor" as you get back from CreateFile(). This is the source of the Warning you got yesterday, and whilst casting gets rid of the warning, it doesn't actually give the RIGHT VALUE that write would expect to use.

WriteFile() will give you the number of bytes written as one of the parameters.