Skip to content

Instantly share code, notes, and snippets.

Created April 2, 2013 22:02
Show Gist options
  • Save anonymous/5296615 to your computer and use it in GitHub Desktop.
Save anonymous/5296615 to your computer and use it in GitHub Desktop.
/**********************************************************************
* main.cpp - CSCI212 - Ass1 - main() driver for displaying ls statistics
* Anthony Burchell-Bailey - 4245490 - /4/2013
**********************************************************************/
#include <iostream>
#include <string>
#include <cstdlib>
#include "linkedlist.h"
using namespace std;
void AddToTail(string newdata, int newdate, int newtim, float newsize); // previous add function
void Print();//prints list. eg 12 34 21 26
int main()
{
cout << "Welcome to ls counter\n";
cout << "User\tFiles\tOldest\t\tLatest\t\tTotSize\n";
LinkedList list;
string newdata = "ant", waste, time, hold;
int newdate = 19930517;
int newmon = 0;
int newday = 0;
int newyea = 0;
int newtim = 0;
float newsize = 20;
cin.ignore(256,'\n');
while(!cin.eof())
{
cin.ignore(20,' ');
cin.ignore(20,' ');
cin.ignore(20,' ');
cin.ignore(20,' ');
getline(cin,newdata,' ');
//cin.ignore(20,' ');
//cin.ignore(20,' ');
//cin.ignore(20,' ');
//cin.ignore(20,' ');
//cin.ignore(20,' ');
//cin.ignore(20,' ');
//cin.ignore(20,' ');
//cin.ignore(20,' ');
scanf("%*s %*d %*s %*s %d",&newsize);
// cin >> newsize;
cin.ignore(20,' ');
getline(cin,waste,' ');
if(waste == "Jan")
{newmon = 100;}
if(waste == "Feb")
{newmon = 200;}
if(waste == "Mar")
{newmon = 300;}
if(waste == "Apr")
{newmon = 400;}
if(waste == "May")
{newmon = 500;}
if(waste == "Jun")
{newmon = 600;}
if(waste == "Jul")
{newmon = 700;}
if(waste == "Aug")
{newmon = 800;}
if(waste == "Sep")
{newmon = 900;}
if(waste == "Oct")
{newmon = 1000;}
if(waste == "Nov")
{newmon = 1100;}
if(waste == "Dec")
{newmon = 1200;}
cin >> newday;
getline(cin,waste,' ');
getline(cin,hold,' ');
if(hold[2] == ':')
{
time[0] = hold[0];
time[1] = hold[1];
time[2] = hold[3];
time[3] = hold[4];
newtim = atoi(time.c_str());
newyea = 20130000;
}
else
{
time[0] = hold[0];
time[1] = hold[1];
time[2] = hold[2];
time[3] = hold[3];
newyea = atoi(time.c_str());
newtim = 0;
}
newdate = newyea + newmon + newday;
getline(cin,waste,'\n');
list.AddToTail(newdata, newdate, newtim, newsize);
}
list.Print();//prints list
cout << "\nThanks for using ls counter\n";
return(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment