stream to byte array

Hi,

I'm creating a program in native C++ (no clr). I'm using a toolkit which converts data and normally writes it to a file or stdout.
The issue is that I want to write it to an array and I don't know the size which will be sent.
The toolkit requires a paramter "FILE *" and cannot be modified.

Basically working code:

FILE * ofile = fopen("yourfile.dat", "wb");
toolkit::function(ofile);
fclose(ofile);

to std out the first line would be FILE * ofile = stdout;

What I want now, is that I have can perform the function end in the end have a pointer to an array op byte (e.g. char *) and the size of it.
I've been looking around an can find the sollution...
First writing to a file is not an option.

Thank you in advance!

Johan
Thanks Helios for the reply.
I looked at it, and also some other posts and apparently there is no nice sollution.

Since the goal of this application was streaming towards a webclient I've used stdout instead of a byte array and an outputstream to redirect it towards the client.

Works like a charm.

Only thing left is that the second time I redirect the stdout it raises an error (without any clear description.)


Going to look into that now.

Thanks,

Johan
Last edited on
Topic archived. No new replies allowed.