M
M
mrxakerrus2018-02-09 23:13:28
C++ / C#
mrxakerrus, 2018-02-09 23:13:28

I need to write to the output stream instead of writing to a file, how to do it?

There is a code

int  RealDataCallBack_V2(long lRealHandle, const PACKET_INFO_EX *pFrame, unsigned int dwUser)
{
       fwrite(pFrame->pPacketBuffer,1,pFrame->dwPacketSize,g_pFile);
}

Instead of fwrite, I tried to write stdout in this case, no output occurs to the console, with fwrite it writes to a file, can someone tell me how to write it in order to output data (in the future I will transfer this data to the ffmpeg program through the console line as a pipe)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Saboteur, 2018-02-10
@mrxakerrus

$ ll
total 12
drwxrwxr-x  2 saboteur saboteur 4096 Feb 10 09:49 ./
drwxr-xr-x 11 saboteur saboteur 4096 Feb 10 09:48 ../
-rw-rw-r--  1 saboteur saboteur  132 Feb 10 09:48 write.cpp
$ cat write.cpp
#include <stdio.h>

int main ()
{
  char buffer[] = { 'w' , 't' , 'f' , '\n' };
  fwrite(buffer , 1 , sizeof(buffer) , stdout );
}
$ gcc write.cpp -o write
$ ./write
wtf
$

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question