This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
user:kkrauss1:portfolio:library_tester [2011/12/12 21:10] – [Background] kkrauss1 | user:kkrauss1:portfolio:library_tester [2011/12/12 21:13] (current) – [Code] kkrauss1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ======Project: | ||
+ | A project for C/C++, Data Structures, and System Programming by Karl Krauss for fall 2011. | ||
+ | |||
+ | Approximately 1 hour for just the tester, then several more for all the libraries. | ||
+ | |||
+ | =====Objectives===== | ||
+ | I had spent a lot of time writing various libraries, this program was written as a way to test them all with subtle changes. | ||
+ | |||
+ | =====Prerequisites===== | ||
+ | In order to successfully accomplish/ | ||
+ | |||
+ | * understand functions | ||
+ | * understand pointers | ||
+ | * understand structs | ||
+ | * understand malloc() | ||
+ | |||
+ | =====Background===== | ||
+ | |||
+ | This was the simplest way I could think of to test all of my libraries. | ||
+ | =====Attributes===== | ||
+ | |||
+ | ====Cprog attributes==== | ||
+ | |||
+ | * variables | ||
+ | * pointers | ||
+ | * selection | ||
+ | * i/o | ||
+ | * repetition | ||
+ | * functions | ||
+ | * structures | ||
+ | * libraries | ||
+ | ====Data Structures==== | ||
+ | * Pointers | ||
+ | * Malloc/new | ||
+ | * linked list | ||
+ | * Doubly linked list | ||
+ | * Libraries | ||
+ | |||
+ | ====Systems programming==== | ||
+ | * Terminal I/O | ||
+ | |||
+ | =====Code===== | ||
+ | This is the code: | ||
+ | <code c> | ||
+ | #include < | ||
+ | #include < | ||
+ | #include " | ||
+ | |||
+ | int main() | ||
+ | { | ||
+ | char selection; | ||
+ | int input; | ||
+ | |||
+ | Node *tmp; | ||
+ | Queue *myQueue; | ||
+ | |||
+ | |||
+ | myQueue=(Queue *)malloc(sizeof(Queue)); | ||
+ | |||
+ | myQueue-> | ||
+ | printf(" | ||
+ | printf(" | ||
+ | printf(" | ||
+ | printf(" | ||
+ | |||
+ | scanf(" | ||
+ | |||
+ | while (selection != ' | ||
+ | { | ||
+ | if (selection == ' | ||
+ | { | ||
+ | printf(" | ||
+ | scanf(" | ||
+ | myQueue = enqueue(myQueue, | ||
+ | } | ||
+ | else if(selection == ' | ||
+ | { | ||
+ | |||
+ | tmp = dequeue(myQueue); | ||
+ | if (tmp == NULL) | ||
+ | { | ||
+ | printf(" | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | printf(" | ||
+ | } | ||
+ | } | ||
+ | else if(selection == ' | ||
+ | { | ||
+ | |||
+ | tmp = peek(myQueue); | ||
+ | if (tmp == NULL) | ||
+ | { | ||
+ | printf(" | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | printf(" | ||
+ | } | ||
+ | } | ||
+ | |||
+ | else | ||
+ | { | ||
+ | printf(" | ||
+ | } | ||
+ | |||
+ | // | ||
+ | // | ||
+ | // | ||
+ | // | ||
+ | // | ||
+ | printf(" | ||
+ | getchar(); | ||
+ | scanf(" | ||
+ | } | ||
+ | |||
+ | return 0; | ||
+ | } | ||
+ | </ |