× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Given the following program

#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
#include <iomanip>

using namespace std;


void redirect(ostream& strm, ofstream& file)
{
// save output buffer of the stream
streambuf* strm_buffer = strm.rdbuf();

// redirect ouput into the file
strm.rdbuf (file.rdbuf());
}


int main(int argc, char* argv[])
{
string filename;
_CCSID_T ccsid(819);

filename = "redirect.log";
ofstream file(filename.c_str(), fstream::out | fstream::app, ccsid);
if (file.is_open()) {
redirect(cerr, file);
}
cerr << "This is some text to print out" << endl;
}

BTW, I usually live and breathe in the QSH environment.

How can I change the output code page of cerr to something besides 37,
which is probably the job's default? What happens here is when the program
is run, output is written to the file, but the program ends with "qsh:
001-0078 Process ended by signal 5.".

"cat redirect.log" prints garbage (EBCDIC)

"setccsid 37 redirect.log" fixes the problem and makes the text readable.


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.