Topic: HELP!!! redirection
Author: grimaldo@nlsce1.seri.philips.nl (Emilio Grimaldo)
Date: Tue, 12 Oct 1993 11:19:55 GMT Raw View
[ Article crossposted from comp.lang.c++ ]
[ Author was Emilio Grimaldo ]
[ Posted on Tue, 12 Oct 1993 10:52:28 GMT ]
Hi,
Excuse my ignorance (not always ignorance is bliss...) but I am
very new to C++, at the moment I am converting one of my existing'
C programs to C++ and I have the following questions:
1) Is sprintf() also considered C++ or is there any new function
that would do the job?
2) Is the default device stdin, stdout etc renamed? I mean for the
purposes of opening a file (see Question 3)
3) My program acts as a filter, the part that concerns me basically is
to have my input from stdin or a file, so I can invoke my program
as:
myprog ; will use stdin
myprogr myfile ; will use myfile instead of stdin
In my C code I have something like (error checking not shown for
clarity):
main(...)
{
FILE *input_stream;
if (argc == 2)
{
input_stream = fopen(argv[1],"r");
}
else
{
input_stream = stdin;
}
.... code ...
}
How can I translate this into pure C++? I think I can use
ifstream file_ptr("JUNK.TXT");
if I would use it right away, but I want to define my input
stream first and then open it for use at some other stage.
Every input would be greatly appreciated, please mail directly
to my email account because lately I have not much time to
check these newsgroups.
Thanks in advance,
Emilio
(suffering nightmares++)
--
NAME: Emilio Grimaldo | Field Appl. Engineer | _/_/_/_/
EMAIL: grimaldo@sce.philips.nl | Telecom/CT1 | _/_/
ADDRESS: Eindhoven,The Netherlands | | _/_/_/_/
-----------------------------------+----------------------| _/_/
* * STRICTLY PERSONAL OPINIONS, I GOT MY OWN MIND :) * * | _/_/_/_/
----------------------------------------------------------+-----------
Hi there! enjoy reading this?
"En b t utan kapten aer som en man utan kvinna"
\\v//
Hullo, I'm just trying to look over the fence :) (o o)
---------------------------------------------------ooO-(_)-Ooo------
--
NAME: Emilio Grimaldo | Field Appl. Engineer | _/_/_/_/
EMAIL: grimaldo@sce.philips.nl | Telecom/CT1 | _/_/
ADDRESS: Eindhoven,The Netherlands | | _/_/_/_/
-----------------------------------+----------------------| _/_/
* * STRICTLY PERSONAL OPINIONS, I GOT MY OWN MIND :) * * | _/_/_/_/
----------------------------------------------------------+-----------
Hi there! enjoy reading this?
"En b t utan kapten aer som en man utan kvinna"
\\v//
Hullo, I'm just trying to look over the fence :) (o o)
---------------------------------------------------ooO-(_)-Ooo------