473,915 Members | 4,599 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

freopen()

After I have redirected output to a file (james.txt)...

freopen("james. txt", "w", stdout);

after the prog has written what needs to be written to the file how do I direct
output back to the monitor?

Thanks :)
Nov 13 '05 #1
1 3394
Teh Charleh wrote:
After I have redirected output to a file (james.txt)...

freopen("james. txt", "w", stdout);

after the prog has written what needs to be written to the file how do I direct
output back to the monitor?


This is a FAQ.

http://www.eskimo.com/~scs/C-faq/q12.34.html

--
Enrico `Trippo' Porreca

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3182
by: Alex Vinokur | last post by:
Hi, Where has output-to-cout gone in the program below? Thanks, ========= C++ code : File foo.cpp : BEGIN ========= #include <cstdio> #include <cassert> #include <iostream>
4
25694
by: Rouben Rostamian | last post by:
Consider the following demo program: #include <stdio.h> int main(void) { unsigned char c; for (c=0; c<15; c++) putchar(c);
2
12625
by: Alex Vinokur | last post by:
Hi, freopen closes stdout, but it seems that fclose doesn't restore it (see sample below). How can one print to stdout after using freopen? ========= C code : File foo.c : BEGIN ========= #include <stdio.h>
8
6092
by: John Forkosh | last post by:
I have a C program that writes binary output to stdout, which works fine in Unix/Linux. But when someone else compiled and ran it in Windows, every time the program emitted a 0x0A, Windows interpreted it as an lf, and preceded it with a spurious 0x0D cr. Cute. Is there some way I can freopen() (so to speak) stdout in binary mode under Windows so that doesn't happen? Hopefully, the fix would be portable, so it could compile and...
3
561
by: John Devereux | last post by:
Hi, I am a bit confused about the behaviour of freopen() and the standard i/o streams. I am trying to redirect a stream (stderr) to a particular "file". But, if the call fails I want it to stay as it was, or at least be able to redirect it somewhere else (e.g. stdout). For example I would like to do,
1
2428
by: joshuawilsonster | last post by:
I have checked: http://c-faq.com/stdio/undofreopen.html and don't believe it addresses my question. I am dealing with large files of numbers and want to take in small chunks and act on them--sometimes using information based on the whole file. My approach is to read in the whole file in chunks, place it in tempfile = tmpfile(); and then run this back through. However, sometimes I will bypass this option and read the chunks outright (not...
1
2154
by: system55 | last post by:
is it possible to reopen a file (using freopen) eventhough that file is already opened by an fopen function???
4
4155
by: Hlk.Turk | last post by:
Hi All, I have a question regarding the standard C library. Is it possible to have one process (program) that redirects its stdin to a file, and have a second program use that file write/append to that file. The first program will then read its redirected standard input file and process that...
2
8516
by: Guillaume Dargaud | last post by:
Hello all, a while ago I was pointed towards freopen as a way to redirect stderr to a log file. It works great, but apparently the app also writes a few lines to stdout. Now I could redirect to 2 separate files, but would rather keep the 2 flows together. Is it correct to do this: stderr=freopen(LogFile, "w", stderr); stdout=freopen(LogFile, "a", stdout);
5
8997
by: Joakim Hove | last post by:
Hello, I have written a program in C; this programs uses an external proprietary library. When calling a certain function in the external library, the particular function writes a message to stdout. I am not particularly interested in this message, and would like to silence it - however I do not know how to do it. (I stdout and stderr my self, so just redirecting into oblivion is not an option). An excerpt of the code looks like this:
0
9881
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10923
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11066
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10542
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9732
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8100
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7256
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3368
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.