Created
July 2, 2009 22:01
-
-
Save sms420/139743 to your computer and use it in GitHub Desktop.
FINAL - clock for Kyle and harvard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //reallySimpleClock.cpp | |
| //for KT_Monda [FINAL] | |
| #include<conio.h> | |
| #include<iostream> | |
| #include<fstream> | |
| #include<ctime> | |
| #include<windows.h> | |
| using namespace std; | |
| int main() | |
| { | |
| ofstream button_E; | |
| ofstream button_I; | |
| button_E.open("e.txt"); | |
| button_I.open("i.txt"); | |
| char INPUT; | |
| string file_e = "e.txt"; | |
| char *e_old=new char[file_e.size()+1]; | |
| e_old[file_e.size()]=0; | |
| memcpy(e_old,file_e.c_str(),file_e.size()); | |
| string file_i = "i.txt"; | |
| char *i_old=new char[file_i.size()+1]; | |
| i_old[file_i.size()]=0; | |
| memcpy(i_old,file_i.c_str(),file_i.size()); | |
| while(1) | |
| { | |
| if(_kbhit()) | |
| { | |
| INPUT = _getch(); | |
| if (strncmp (&INPUT,"e",1) == 0) | |
| { button_E << clock() << endl; } | |
| if (strncmp (&INPUT,"i",1) == 0) | |
| { button_I << clock() << endl; } | |
| if(INPUT==27) // ESC | |
| { | |
| break; | |
| } | |
| }//closes _kbhit | |
| }//closes while | |
| button_E.close(); | |
| button_I.close(); | |
| string e, i, subject; | |
| string ans; | |
| do{ | |
| cout << "subject number: "; | |
| cin >> subject; | |
| cin.ignore(80,'\n'); | |
| cout << "you've entered: " << subject << endl; | |
| cout << "is this correct?\nHit [Y/y] for yes or any other key for No: "; | |
| cin >> ans; | |
| cin.ignore(80,'\n'); | |
| char *again=new char[ans.size()+1]; | |
| again[ans.size()]=0; | |
| memcpy(again,ans.c_str(),ans.size()); | |
| if ((again[0]=='y') || (again[0]=='Y')) | |
| break; | |
| cout << "YOUR ENTRY WAS NOT RECORDED, PLEASE ENTER AGAIN\n"; | |
| }while(1); | |
| e = subject; | |
| i = subject; | |
| e.append( 1, '_' ); | |
| e.append( 1, 'e' ); | |
| e.append( 1, '.' ); | |
| e.append( 1, 't' ); | |
| e.append( 1, 'x' ); | |
| e.append( 1, 't' ); | |
| i.append( 1, '_' ); | |
| i.append( 1, 'i' ); | |
| i.append( 1, '.' ); | |
| i.append( 1, 't' ); | |
| i.append( 1, 'x' ); | |
| i.append( 1, 't' ); | |
| char *e_new=new char[e.size()+1]; | |
| e_new[e.size()]=0; | |
| memcpy(e_new,e.c_str(),e.size()); | |
| char *i_new=new char[i.size()+1]; | |
| i_new[i.size()]=0; | |
| memcpy(i_new,i.c_str(),i.size()); | |
| rename(i_old, i_new); | |
| rename(e_old, e_new); | |
| return 0; | |
| }//closes program |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment