Search
 
SCRIPT & CODE EXAMPLE
 

CPP

what is stdoutread in c++

// make a temp file to store the function's stdout
int newStdOut = mkstemp( "/tmp/stdout.XXXXXXX" );

// save the original stdout
int tmpStdOut = dup( STDOUT_FILENO );

// clear stdout
fflush( stdout );

// now point the stdout file descriptor to the file
dup2( newStdOut, STDOUT_FILENO );

// call the function we want to collect the stdout from
some_function();

// make sure stdout is empty
fflush( stdout );

// restore original stdout
dup2( tmpStdOut, STDOUT_FILENO );

// the tmp file now contains whatever some_function() wrote to stdout
Comment

PREVIOUS NEXT
Code Example
Cpp :: determining a string is subsequence of another 
Cpp :: Diamond pattren program in C++ 
Cpp :: convert c program to c ++ online 
Cpp :: c++ cyclic barrier 
Cpp :: run program until ctrl-d c++ 
Cpp :: c++ first index 0 or 1 
Cpp :: export gcc g++ 
Cpp :: online compiler c++ with big O calculatorhttps://www.codegrepper.com/code-examples/cpp/how+to+convert+string+to+wchar_t+in+c%2B%2B 
Cpp :: Boats to Save People leetcode solution in c++ 
Cpp :: pcl c++ read .pcd 
Cpp :: erase in c++ 
Cpp :: No Index Out of Bound Checking in C++ 
Cpp :: how to test if char in = to another in c++ 
Cpp :: store binary data in buffer 
Cpp :: c++ synchronization primitives example programs 
Cpp :: ‘npos’ is not a member of ‘std’ 
Cpp :: cuda allocate memory 
Cpp :: Int main ( ) { int i,n; cinn; i=n; while(i=1) { i=i+5; i=i-6; } } 
Cpp :: graph colouring backtracking 
Cpp :: how to find second smallest element using single loop 
Cpp :: pca compact trick 
Cpp :: c++ power operator 
Cpp :: what is the format specifier for dword c++ 
Cpp :: compile c++ MPI Program 
Cpp :: how to implement stack 
Cpp :: c++ vector remove element by value 
Cpp :: inpout in Array c++ 
Cpp :: imgui menu bar 
Cpp :: english to french typing online 
C :: Write a C program to print all unique elements in the array. 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =