Buffer to char[] ?!?!?


Guys, help me, please.

I am altering a old program and I have a doubt.

Currently, the point of program which I'll alter is doing this:

fwrite (buffer, size << 2, 1, file) != 1)

But, I cant write the file at program. I need send the informations to a host, by socket. So, the fwrite will be in host.

In the program, in the local which actually is the fwrite, I will put a command which will send the "message" to host.

The problem is:
My server socket is waiting a char[] and in this point of the program I have only the buffer. How can I convert the buffer to a char[] that I can send to my socket server?

Thanks,
Harry
Let me see if I understand. What you want is to write the data from buffer to a char[] instead of a file, am I right?

In case I am, is there any reason you couldn't use a loop to copy the bytes from buffer into your char[] one by one, using pointer arithmetic? {:/

-Albatross
Last edited on
I believe Albatross is correct in the above assertion. However, the buffer parameter of the fwrite is a void pointer to the address of a block of data. In order to better understand your problem, I'll need to know what type of information is contained in that block. For example, it makes a world of difference whether you're pointing to a string, a wstring, a wchar_t, etc...
Last edited on
Topic archived. No new replies allowed.