PLEASE HELP - How to rename a block of binary bytes to a file

C

cpptutor2000

Could some C/Unix guru please help me with an odd problem I am
having? I am using gcc on an embedded Linux device.

I have a function return a block of bytes and I want to copy them into
an empty file, all inside a function. For example, I would ideally
like to have something like following:

/*some function returns a pointer to a block of unsigned chars - this
part works fine
*/
sprintf(pBuff, "fopen file_name \"%s\"\n", "wb");
Now the question is how do I copy the block of bytes
obtained just above, to the file I have just opened?

Any hints or suggestion would be greatly appreciated - thank you in
advance for your help.
 
S

santosh

Could some C/Unix guru please help me with an odd problem I am
having? I am using gcc on an embedded Linux device.

I have a function return a block of bytes and I want to copy them into
an empty file, all inside a function. For example, I would ideally
like to have something like following:

/*some function returns a pointer to a block of unsigned chars - this
part works fine
*/
sprintf(pBuff, "fopen file_name \"%s\"\n", "wb");

This is wrong.
Now the question is how do I copy the block of bytes
obtained just above, to the file I have just opened?

Open your file with fopen and write to it with fwrite and close with
fclose. Why shouldn't this method work for you?

<snip>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top