Skip to content

Instantly share code, notes, and snippets.

@sms420
Created June 14, 2009 23:17
Show Gist options
  • Save sms420/129863 to your computer and use it in GitHub Desktop.
Save sms420/129863 to your computer and use it in GitHub Desktop.
/* FINAL_FED_EX_SCRIPT.cpp
*********************************************************/
#include<iostream>
#include<fstream>
#include<string.h>
using namespace std;
int main () {
string temp_string;// temporary string to hold line of data
ifstream inputFile ("INPUT.txt");
ofstream outputFile_tmp;
outputFile_tmp.open("DUDE_tmp.txt");
if (inputFile.is_open())
{
// scrap the first line of the text file
getline (inputFile,temp_string);
while (! inputFile.eof() )
{
// read line from INPUT.txt & copy to temp_string
getline (inputFile,temp_string);
// dynamically alocate enough memory for char array
char *a=new char[temp_string.size()+1];
// assign zero to the first value in the array
a[temp_string.size()]=0;
// copy data from temp_string into char array
memcpy(a,temp_string.c_str(),temp_string.size());
// write to outputFile, character, by character
for (int i = 0; i < temp_string.size(); i++)
{
// if the machine encounters a comma, add newline
if (strncmp (&a[i],",",1) == 0)
{ outputFile_tmp << endl; }
// if the machine encounters a quote, delete it
else if (strncmp (&a[i],"\"",1) == 0)
{ continue; }
else
{ outputFile_tmp << a[i]; }
}
outputFile_tmp << endl;
} // closes: while (! inputFile.eof() )
inputFile.close();
outputFile_tmp.close();
} // closes: if (inputFile.is_open())
// now that everything is clean, let's
// get down and dirty with parsing the
// date formatted object
ifstream inputFile_tmp ("DUDE_tmp.txt");
ofstream outputFile;
outputFile.open("OUTPUT.txt");
if (inputFile_tmp.is_open())
{
// scrap the first 2 lines of the text file
getline (inputFile_tmp,temp_string);
getline (inputFile_tmp,temp_string);
/** GET THE DATE **/
while (! inputFile_tmp.eof() )
{
// read line from temp input file & copy to temp_string
getline (inputFile_tmp,temp_string);
// dynamically alocate enough memory for char array
char *a=new char[temp_string.size()+1];
// assign zero to the first value in the array
a[temp_string.size()]=0;
// copy data from temp_string into char array
memcpy(a,temp_string.c_str(),temp_string.size());
// write to outputFile, character, by character
for (int i = 0; i < temp_string.size(); i++)
{
outputFile << "DO" << endl;
outputFile << a[4]
<< a[5]
<< a[6]
<< a[7]
<< a[2]
<< a[3];
break;
}
outputFile << endl;
/** GET THE CM **/
getline (inputFile_tmp,temp_string);
// dynamically alocate enough memory for char array
char *b=new char[temp_string.size()+1];
// assign zero to the first value in the array
b[temp_string.size()]=0;
// copy data from temp_string into char array
memcpy(b,temp_string.c_str(),temp_string.size());
// write to outputFile, character, by character
for (int i = 0; i < temp_string.size(); i++)
{
outputFile << b[i];
}
outputFile << endl << "1" << endl << "-" << endl;
/* DELETE THE NEXT LINE */
getline (inputFile_tmp,temp_string);
/* GET THE COST */
getline (inputFile_tmp,temp_string);
// dynamically alocate enough memory for char array
char *d=new char[temp_string.size()+1];
// assign zero to the first value in the array
d[temp_string.size()]=0;
// copy data from temp_string into char array
memcpy(d,temp_string.c_str(),temp_string.size());
// write to outputFile, character, by character
for (int i = 0; i < temp_string.size(); i++)
{
outputFile << d[i];
}
outputFile << endl
<< "HMSG" << endl
<< "-" << endl
<< "-" << endl
<< "01" << endl
<< "-" << endl
<< "LJ08" << endl
<< "-" << endl
<< "-" << endl
<< "-" << endl << endl << endl;
/* DELETE THE NEXT TWO LINES */
getline (inputFile_tmp,temp_string);
getline (inputFile_tmp,temp_string);
} // closes: while (! inputFile_tmp.eof() )
inputFile_tmp.close();
outputFile.close();
} // closes: if (inputFile_tmp.is_open())
return 0;
} //** closes: main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment