diff --git a/COM390/Project4/CoverSheet.docx b/COM390/Project4/CoverSheet.docx new file mode 100644 index 0000000..adf5c20 Binary files /dev/null and b/COM390/Project4/CoverSheet.docx differ diff --git a/COM390/Project4/Project 4.pdf b/COM390/Project4/Project 4.pdf new file mode 100644 index 0000000..2667614 Binary files /dev/null and b/COM390/Project4/Project 4.pdf differ diff --git a/COM390/Project4/Project4/Helper.c b/COM390/Project4/Project4/Helper.c index 1a672d1..aba8951 100644 --- a/COM390/Project4/Project4/Helper.c +++ b/COM390/Project4/Project4/Helper.c @@ -1,45 +1,48 @@ -#include "Project4.h" - -#include +#include "Helper.h" void pause() { printf("\n%s\n", "Press any key to continue. . ."); getch(); } -void clrscr() - { - HANDLE hStdOut; - CONSOLE_SCREEN_BUFFER_INFO csbi; - DWORD count; - DWORD cellCount; - COORD homeCoords = { 0, 0 }; +void clrscr() { + HANDLE hStdOut; + CONSOLE_SCREEN_BUFFER_INFO csbi; + DWORD count; + DWORD cellCount; + COORD homeCoords = { 0, 0 }; + COORD consoleSize = { 24, 80 }; + COORD consoleWipe = { 0, 0 }; + int minx; + int miny; - hStdOut = GetStdHandle( STD_OUTPUT_HANDLE ); - if (hStdOut == INVALID_HANDLE_VALUE) return; + minx = GetSystemMetrics(SM_CXMIN); + miny = GetSystemMetrics(SM_CYMIN); - /* Get the number of cells in the current buffer */ - if (!GetConsoleScreenBufferInfo( hStdOut, &csbi )) return; - cellCount = csbi.dwSize.X *csbi.dwSize.Y; + hStdOut = GetStdHandle( STD_OUTPUT_HANDLE ); + if (hStdOut == INVALID_HANDLE_VALUE) return; - /* Fill the entire buffer with spaces */ - if (!FillConsoleOutputCharacter( - hStdOut, - (TCHAR) ' ', - cellCount, - homeCoords, - &count - )) return; + // Get the number of cells in the current buffer + if (!GetConsoleScreenBufferInfo( hStdOut, &csbi )) return; + cellCount = csbi.dwSize.X *csbi.dwSize.Y; + consoleSize = csbi.dwSize; - /* Fill the entire buffer with the current colors and attributes */ - if (!FillConsoleOutputAttribute( - hStdOut, - csbi.wAttributes, - cellCount, - homeCoords, - &count - )) return; + + if (!SetConsoleScreenBufferSize(hStdOut, consoleWipe)) { + return; + } + /* + if (!SetConsoleScreenBufferSize(hStdOut, consoleSize)) { + return; + } + */ - /* Move the cursor home */ - SetConsoleCursorPosition( hStdOut, homeCoords ); - } \ No newline at end of file + // Fill the entire buffer with spaces + if (!FillConsoleOutputCharacter(hStdOut, (TCHAR) ' ', cellCount, homeCoords, &count)) return; + + // Fill the entire buffer with the current colors and attributes + if (!FillConsoleOutputAttribute(hStdOut, csbi.wAttributes, cellCount, homeCoords, &count)) return; + + // Move the cursor home + SetConsoleCursorPosition( hStdOut, homeCoords ); + } \ No newline at end of file diff --git a/COM390/Project4/Project4/Helper.h b/COM390/Project4/Project4/Helper.h new file mode 100644 index 0000000..dbb6a13 --- /dev/null +++ b/COM390/Project4/Project4/Helper.h @@ -0,0 +1,9 @@ +#include +#include +#include +#include + +void init(); +void down(); +void pause(); +void clrscr(); diff --git a/COM390/Project4/Project4/Project4.c b/COM390/Project4/Project4/Project4.c index 0c2aa16..ed47327 100644 --- a/COM390/Project4/Project4/Project4.c +++ b/COM390/Project4/Project4/Project4.c @@ -1,15 +1,25 @@ -// Project4.cpp : Defines the entry point for the console application. -// +/****************************************************************************** + * Author: Amrit Panesar + * Project: 4 - Structs/Malloc + * Date: 09/08/2015 + * Purpose: Create a multidimensional array on the fly and populate its children + * Display the results. + *****************************************************************************/ #include "Project4.h" -#define holdsize 5 +#define holdsize 10 -TtimeStruct holding[holdsize]; +TtimeStruct* holding; int i, j ,k = 0; + void init() { + srand(time(NULL)); + + holding = (TtimeStruct*)malloc(sizeof(TtimeStruct) * holdsize); + for (i = 0; i < holdsize; i++) { holding[i] = (TtimeStruct)malloc(sizeof(TravTimeStruct)); } @@ -17,9 +27,19 @@ void init() { void getInputs() { for (i = 0; i < holdsize; i++) { - clrscr(); - printf("%s%d\n\n", "Input for #", i); - printf("%s\n:", "Please enter a speed"); + holding[i]->currentTimestamp = time(NULL); + holding[i]->distance = rand()%100; + holding[i]->speed = rand()%100; + } +} + +void printStructs() { + for (i = 0; i < holdsize; i++) { + printf("%s%d\n", "Structure #", i); + printf("%s%d\n", "Time: ", holding[i]->currentTimestamp); + printf("%s%d\n", "Distance: ", holding[i]->distance); + printf("%s%d\n", "Speed: ", holding[i]->speed); + printf("%s\n\n", "-----------------------"); } } @@ -27,10 +47,11 @@ int main(int argc, char **argv) { init(); getInputs(); - - pause(); + printStructs(); down(); + + pause(); return 0; } @@ -38,4 +59,5 @@ void down() { for (i = 0; i < holdsize; i++) { free(holding[i]); } + free(holding); } diff --git a/COM390/Project4/Project4/Project4.h b/COM390/Project4/Project4/Project4.h index 02469c2..70ce613 100644 --- a/COM390/Project4/Project4/Project4.h +++ b/COM390/Project4/Project4/Project4.h @@ -1,22 +1,26 @@ +/****************************************************************************** + * Author: Amrit Panesar + * Project: 4 - Structs/Malloc + * Date: 09/08/2015 + * Purpose: Create a multidimensional array on the fly and populate its children + * Display the results. + *****************************************************************************/ #include #include #include #include #include +#include #define true 1; #define false 0; -typedef struct +typedef struct { - float speed; - float distance; - float timetraveled; + int speed; + int distance; + time_t currentTimestamp; } TravTimeStruct, *TtimeStruct; - -void init(); -void down(); -void pause(); -void clrscr(); \ No newline at end of file +#include "Helper.h" diff --git a/COM390/Project4/Project4/Project4.vcxproj b/COM390/Project4/Project4/Project4.vcxproj index 77833e0..d988eb1 100644 --- a/COM390/Project4/Project4/Project4.vcxproj +++ b/COM390/Project4/Project4/Project4.vcxproj @@ -83,6 +83,7 @@ + diff --git a/COM390/Project4/Project4/Project4.vcxproj.filters b/COM390/Project4/Project4/Project4.vcxproj.filters index db3b401..a76bda0 100644 --- a/COM390/Project4/Project4/Project4.vcxproj.filters +++ b/COM390/Project4/Project4/Project4.vcxproj.filters @@ -21,10 +21,16 @@ Header Files + + Header Files + Source Files + + Source Files + \ No newline at end of file diff --git a/COM390/Project4/ScreenShots.docx b/COM390/Project4/ScreenShots.docx new file mode 100644 index 0000000..6d33af9 Binary files /dev/null and b/COM390/Project4/ScreenShots.docx differ diff --git a/SublimeTextIntegration.cmd b/SublimeTextIntegration.cmd new file mode 100644 index 0000000..bf84b29 --- /dev/null +++ b/SublimeTextIntegration.cmd @@ -0,0 +1,13 @@ +@echo off +SET st2Path=C:\Program Files\Sublime Text 3\sublime_text.exe + + +@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text" /t REG_SZ /v "" /d "Open with Sublime Text" /f +@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text" /t REG_EXPAND_SZ /v "Icon" /d "%st2Path%,0" /f +@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text\command" /t REG_SZ /v "" /d "%st2Path% \"%%1\"" /f + +@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text" /t REG_SZ /v "" /d "Open with Sublime Text" /f +@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text" /t REG_EXPAND_SZ /v "Icon" /d "%st2Path%,0" /f +@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text\command" /t REG_SZ /v "" /d "%st2Path% \"%%1\"" /f + +pause \ No newline at end of file