This file contains 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
// Binary Search Tree Node | |
#pragma once | |
template <typename T> | |
class BST_Tree; | |
template <typename T> | |
class BST_Node | |
{ | |
public: |
This file contains 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
/********************************************************************** | |
* Function: padString(char *string, size_t size, fillchar) | |
* Purpose: padString for writing specific data file | |
* Precondition: pass string, total string size desired, and fillchar | |
* Postcondition: string is padded with fillchar | |
************************************************************************/ | |
void padString(char *string, size_t size, char fillchar) | |
{ | |
size_t i = 0; | |
while(*string != 0) |
This file contains 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
pid_t create_process(char *cmd, int file_input, int file_output) | |
{ | |
pid_t pid = -1; | |
char **array_args = NULL; | |
pid = fork(); | |
if(pid == 0) | |
{ | |
//child |
This file contains 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
/********************************************************************** | |
* Function: void remove_control_characters(char *str_line) | |
* implemented for good measure | |
* Purpose: remove all control characters from a string | |
* Precondition: pass a string | |
* Postcondition: all control characters removed from string | |
************************************************************************/ | |
void remove_control_characters(char *str_line) | |
{ | |
if(str_line != NULL) |
This file contains 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
void ChompStringFromEnd(char *string, char chompChar) | |
{ | |
int len = strlen(string); | |
while(string[len--] != chompChar && len >= 0) | |
{ | |
if(string[len] == chompChar) | |
{ | |
string[len + 1] = 0; | |
break; | |
} |
This file contains 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
char **GetTokens(char *tokens, const char *delim) | |
{ | |
char *index = NULL; | |
char **cmdArgs = NULL; | |
int argCount = 0; | |
index = strtok(tokens, delim); | |
while(index) | |
{ | |
cmdArgs = (char**)realloc(cmdArgs, sizeof(char*) * (argCount + 1)); |
This file contains 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
// Returns proccess return value | |
int CreateProcess(char **cmdArgs) | |
{ | |
pid_t pid = 0; | |
int rval = 0; | |
pid = fork(); | |
// if pid == 0 then I'm in child | |
if(pid == 0) |
This file contains 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
/********************************************************************** | |
* Function: trim_string(" my string ") | |
* Purpose: trims spaces from front and back. | |
* Precondition: a string pointer | |
* Postcondition: string without leading or following spaces | |
************************************************************************/ | |
void trim_string(char *string) | |
{ | |
left_trim(string); | |
right_trim(string); |
This file contains 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
#define COLOR_RED "\x1b[31m" | |
#define COLOR_GREEN "\x1b[32m" | |
#define COLOR_YELLOW "\x1b[33m" | |
#define COLOR_BLUE "\x1b[34m" | |
#define COLOR_MAGENTA "\x1b[35m" | |
#define COLOR_CYAN "\x1b[36m" | |
#define COLOR_RESET "\x1b[0m" | |
printf(COLOR_RED "This is RED" COLOR_RESET); |
This file contains 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
char *GetLine() | |
{ | |
size_t current_line_size = MAX_STR; | |
char *str_line = NULL; | |
char c = 0; | |
size_t index = 0; | |
str_line = malloc(sizeof(char) * current_line_size); | |
while((c = fgetc(stdin)) != '\n') | |
{ |