Skip to main content

Questions tagged [freopen]

freopen reopens a stream with a different file or mode.

freopen
0 votes
0 answers
11 views

Console screen import/export error when using freopen

Can anyone tell me that when using freopen, sometimes when I call new functions using input and output commands on the console screen, it doesn't work? When running, it still works and still processes ...
Thông Lúc's user avatar
0 votes
1 answer
141 views

Why does redirecting the output of assert() work when done using freopen() and stderr but not when redirecting the buffer of std::cerr normally?

I'd like to redirect the output that assert() creates when an assertion fails, so that it is written to a log file instead of the output window. I assumed assert() uses std::cerr to output but when ...
JensB's user avatar
  • 939
1 vote
1 answer
91 views

Bash redirect to stdin after freopen()

I'm encountering a limitation of bash input redirection that's preventing me from accomplishing a task, and I haven't been able to find a way to work around it so far. Essentially, I need to be able ...
Owen Sullivan's user avatar
-1 votes
1 answer
130 views

C++ - my program stops running `freopen` function from <cstdio>

In my main.cpp: #include <cstdio> #include "hashtable.h" int main() { printf("1hello"); freopen("2.txt", "w", stdout); printf("2hello&...
I am done's user avatar
-1 votes
1 answer
136 views

C++: freopen (and I/O) just refuses to work

Today I'm having issues with my code. It appears that I can not get anything from input (whether file or stdin) as well as unable to print (whether from file or stdout). My code can have a lot of ...
ducbadatchem's user avatar
2 votes
1 answer
288 views

Why does reopening stdout to a newly-allocated console occasionally fail?

Consider this program: #include <windows.h> #include <stdio.h> #pragma comment(linker, "/SUBSYSTEM:CONSOLE") int main(void) { if (!FreeConsole()) { MessageBoxA(NULL,...
Joseph Sible-Reinstate Monica's user avatar
0 votes
2 answers
187 views

Console outputs gibberish code after re-redirecting stdout to CON

When I use C++ to invoke Python program output (By system command with parameters), it outputs gibberish code at the end of line. After that, I couldn't input any character (Include Backspace and ...
Yuchen Ren's user avatar
0 votes
1 answer
562 views

use freopen() and scanf() to read an int from file

I try to read an int from a file using freopen(). File in.txt simply have a number:1, but what I get in output is -858993460. My code is shown below: #include <cstdio> #pragma warning(disable:...
uesr12314's user avatar
0 votes
2 answers
339 views

Dynamic file stream handling in C with freopen

I am trying to write a program that ideally accepts arguments that specify both a source file (to read from) and a destination file (to write to). The program replaces specified characters in source ...
croblin's user avatar
  • 61
0 votes
1 answer
53 views

Debug & run result differ in simple c app that redirects stdout using freopen

I'm using linux manjaro. I have the following code (cons.c) #include <stdio.h> #include <stdlib.h> int main() { FILE *f=freopen("/dev/null", "a", stdout); //...
NoComprende's user avatar
0 votes
2 answers
419 views

Freopen not writing output after a function call

I was doing a programming question and was using freopen to redirect the streams. The problem I am facing is that the printf command is not printing on the output file after stdout redirection. I even ...
Dhruv's user avatar
  • 311
1 vote
1 answer
203 views

Extra output when writing to file using std::cout

I am trying to read data from a file in.txt, and after some computations, I am writing the output to out.txt Why is there an extra 7 at the end of out.txt? Contents of Solution class. class Solution { ...
Aditya Wagh's user avatar
1 vote
1 answer
665 views

Not getting output using freopen in c++ :-vs code showing

#include <iostream> using namespace std; int main() { #ifdef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #...
Nitesh Singh's user avatar
0 votes
0 answers
121 views

cin doesn't work along with freopen in wsl windows

I am running this simple cpp code in wsl and it outputs infinite times. The reason being when I take input into the variable t, it simply doesn't take, and it still has the garbage value initiated to ...
Parthiv Reddy's user avatar
0 votes
1 answer
996 views

freopen() does not read / write to existing file, niether creates new file in vscode

I am trying to read input and output from two separate text files in C++. Code(test.cpp): #include<bits/stdc++.h> using namespace std; int main() { #ifndef ONLINE_JUDGE freopen("...
Vishwas's user avatar
  • 11

15 30 50 per page
1
2 3 4 5
7