How do you redirect a standard stream?



How do you redirect a standard stream?..

Answer / Anurag Singh Gautam

In C, you can redirect standard streams (like stdout or stderr) by assigning a pointer to a different output stream. For example, to redirect stdout to a file called 'output.txt', you would use: <pre>nfreopen("output.txt", "w", stdout);n</pre> This code opens the file in write mode and sets it as the new destination for stdout.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

What is the basic structure of c?

1 Answers  


identify the in correct expression a.a=b=3=4; b.a=b=c=d=0; float a=int b=3.5; d.int a; float b; a=b=3.5;

8 Answers   TCS,


How many types of operator or there in c?

1 Answers  


What is pointer in c?

1 Answers  


What is that continue statement??

4 Answers  


what is a constant pointer in C

1 Answers  


what is bit rate & baud rate? plz give wave forms

1 Answers  


How do we print only part of a string in c?

1 Answers  


What will the preprocessor do for a program?

1 Answers   Aspire, Infogain,


int main() { int x = (2,3,4); int y = 9,10,11; printf("%d %d",x,y); } what would be the output?

7 Answers   Parimal, Wipro,


differnce between do and do while

3 Answers   DOEACC,


Tell me when is a void pointer used?

1 Answers  


Categories