This question could mean one of two things: either the program should print its machine code, or it should print its source code. Printing the machine code is easy enough since the first argument passed to the program contains the executable name. So you simply need to open this file as a binary input file and redirect the content to std::cout. Some characters will be non-printable of course, so it might be better to convert every byte to its hexadecimal equivalent and print that instead.
A machine code program that prints its own source is somewhat more complex. Firstly, you need to know which file or files to print. If the source code is contained in a single source file then it's relatively simple to print the one file provided you tell the program which file to print. Using the executable file name to derive the source code file name is one possibility. And if the source has a header this could also be derived.
If the program source is spread over multiple sources with many includes then you should locate the project file that lists all the files used by the project and parse this file in order to obtain each file name you need to print. You can safely ignore standard library includes and binary library links since you'd only be interested in your own user-defined files. Ideally these will all be placed in the same folder so they'll be easy to identify. You might also have re-usable code modules in other folders but if they're all within the same folder hierarchy they should be easy to identify as well. Once you have a list of all the project files files you can go ahead and print them.
To print the output of a C++ console program (or indeed any console program), redirect the output to a file then print the file. If you have a line printer attached to LPT1, redirect to LPT1. Redirection is achieved from the command line. Redirection does not affect error output (std::cerr), only standard output (std::cout).
You print the output of a C++ console program by redirecting the output to the appropriate output stream (display, printer or file). This is achieved via the command line. For example:
progname >> LPT1
In this case, all output that is directed to stdout (which defaults to the display device) will be redirected to the device associated with LPT1 instead. Output that is directed to stderr will not be affected, so errors will be directed to the default stderr device (usually the display device).
Yes.
example output of c++ calculator
input is the << operator and output is the >> operator
There is no such thing as a null printer in C++. You are perhaps thinking of the null device to which output can be redirected from the command line (effectively hiding the output of a program). However this has nothing whatsoever to do with C++, it is entirely dependant upon the operating system.
That is STANDARD input and STANDARD output. By default, standard input is the keyboard, and standard output is the screen. Standard I/O is set by the operating system, though it may be redirected by script invocation or system commands within the C/C++ program itself. You could, for instance, set standard output to a printer or a file in lieu of a screen. You should also Google Standard Error.
its supposed to have an asterisk there before the 's but it wouldnt print it
example output of c++ calculator
For basic input and output in C++: #include
Pipe the output to the MORE command.
input is the << operator and output is the >> operator
You use output devices or streams, typically console screens, printers and files.
See sources and related links below.
No. In C++ with <iostream>, cin is a prefedined class that represents stdin, so it is an input identifier.
The C and C++ library routines for output might, or might not, include use of different buffers. If they are the same buffer (unlikely) then you can simply intermix the techniques. If they are not the same buffer then you need to do a flush sequence between techniques.
There is no such thing as a null printer in C++. You are perhaps thinking of the null device to which output can be redirected from the command line (effectively hiding the output of a program). However this has nothing whatsoever to do with C++, it is entirely dependant upon the operating system.
That is STANDARD input and STANDARD output. By default, standard input is the keyboard, and standard output is the screen. Standard I/O is set by the operating system, though it may be redirected by script invocation or system commands within the C/C++ program itself. You could, for instance, set standard output to a printer or a file in lieu of a screen. You should also Google Standard Error.
I guess you mean either input/output/inout/append or binary/text.
In Ir 4750 Printout remove by hand