Sir,I am unable to take input and output from file,I have followed all the steps.
Unable to take input from file
yes sir I have saved in same directory.
Regardless of where you save your file, you have to type complete address
you can copy paste the entire address of the file from the file info
#this was for Mac users
can I share you the ss of error which is coming in it.
sure!!
You can share the ss, also share what are you typing as code(may be just that part where you incur problem)
Get-Content ./square.exe < input_file.txt
Try this once
Write this in main() function of c++ code;
freopen(“input_file.txt”,“r”,stdin);
#I don’t know why this is incurring to powershell (may be some version related issue)
Above will work
It usually works for all;
Please take a over look at syntax
here https://www.geeksforgeeks.org/io-redirection-c/
// For getting input from input.txt file
freopen
(
"input.txt"
,
"r"
, stdin);
// Printing the Output to output.txt file
freopen
(
"output.txt"
,
"w"
, stdout);
Sir please help,I am a beginner in c++,I am unable to understand the concept taught in geeksforgeeks.
I have put the header file also
#includefstream
Hi, do two things
Include #include < bits/stdc++.h >
and then
write freopen(“input_file.txt”, “r”, stdin)
in main function…
Hope it is good
Okay you have not installed bits/stdc++.h
Alright you install it, it will help you in future without much tension of including particular libraries (for installation you can simply google)
Here you type this inplace of above #include < cstdio >
(https://en.cppreference.com/w/cpp/header/cstdio)