View Single Post
  #22 (permalink)  
Old March 31st, 2004, 02:12 PM
CNewbie CNewbie is offline
Authorized User
 
Join Date: Mar 2004
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Finally got past the Problem with Calculating for the Correct length thanks to Dave:

Code:
#include <fstream>
#include <iostream>
#include <cstring>
#include <ctime>
using namespace std;

void TimeHeader(),StoreINSLength();

struct tm *area;
char *tzstr = "TZ=EST5EDT";
char RawPacket[227];
int INSLength;

int main()
{ 
    fstream Log("Log.txt",ios::in);
    fstream Parse("Parsed.txt",ios::out|ios::app);
    Log.getline(RawPacket,227);

    StoreINSLength();
    TimeHeader();
    Parse << asctime(area) << endl;
    Parse << "> " << RawPacket[0] << RawPacket[1] << " "
          << RawPacket[2] << RawPacket[3] << " "
          << RawPacket[4] << RawPacket[5] << " "
          << RawPacket[6] << RawPacket[7] << " "
          << RawPacket[8] << RawPacket[9] << endl
          << "< " << RawPacket[10] << RawPacket[11] << endl
          << "> ";
    Log.close();
    Parse.close();

return 0;
}
/***************************************
 Display Time Header
****************************************/
void TimeHeader()
{
   time_t t;

   putenv(tzstr);
   tzset();

   t = time(NULL);
   area = localtime(&t);
}
/***************************************
 Store INS Length
****************************************/
void StoreINSLength()
{
    INSLength = (RawPacket[0]-'0')*10+(RawPacket[1]-'0');
    cout << INSLength << endl;
}
Reply With Quote