// serializecrypto.cpp // Israel Torres < israel at israeltorres dot org > // This program will open a named file and serialize newline data for further processing // reconfigured data will output to both console and new file. // WIN32 XPSP2 / VS6 // http://tools.israeltorres.org/serializecrypto.cpp // v 1.0 - 05 / 13 / 2007 //////////////////////////////////////////////////////////////////////////////////////// #include #include #include #include #define IO_BUFF 765 + 1 void main(int argc, char* argv []) { // do a simple check to make sure this is being used as expected. if (argc != 3) { cout << "serializecrypto v1.0 tools.israeltorres.org" << endl; cout << "serializecrypto.exe crypto_in crypto_out" << endl; exit(1); } // open named files for input/output ifstream crypto_in(argv[1]); // note: no input checking ofstream crypto_out(argv[2]); // note: no input checking // create string structures char sz_crypto_in[IO_BUFF]="\0"; char sz_crypto_out[IO_BUFF]="\0"; // use the input named file until its eof while (!(crypto_in.eof())) { // reach each new line and calculate length crypto_in.getline(sz_crypto_in,IO_BUFF,'\n'); int xlen = strlen(sz_crypto_in); // copy each line and strip out newline for restructuring if (sz_crypto_in[xlen-1] == char(13)) strncpy(sz_crypto_out,sz_crypto_in,(xlen-1)); else strcpy(sz_crypto_out,sz_crypto_in); // output to console (replace spacing) cout << sz_crypto_out << " "; // output to file (replace spacing) crypto_out << sz_crypto_out << " "; // clear out our strings memset(sz_crypto_in, 0, sizeof(sz_crypto_in)); memset(sz_crypto_out, 0, sizeof(sz_crypto_out)); } // close files crypto_in.close(); crypto_out.close(); }