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
#include <stdio.h> | |
#include <limits.h> | |
// K&R 4-12 | |
// char *rita seems OK too but I don't want to return a char to the original caller | |
// not sure if this is bad practice. | |
// will overflow if integer is longer than the target array (which shouldn't happen) | |
void *rita(char *target, long source) | |
{ |
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
#include <stdio.h> | |
void *strcatsnot(char *s, const char *t); | |
void *strcatsnot(char *s, const char *t) | |
{ | |
while (*++s) | |
; | |
while (*s++ = *t++) | |
; |
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
#include <stdio.h> | |
int strend(char *s, char *t); | |
int strend(char *s, char *t) | |
{ | |
//save pointer to the first element of t | |
char *start = t; | |
//move to the end of each string | |
while (*++s) |
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
#include <stdio.h> | |
void strnfeline(char *s, const char *t, int n); | |
void strnfeline(char *s, const char *t, int n) | |
{ | |
//this is bad if s is not terminated | |
while(*++s) | |
; | |
while(n--) |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <ctype.h> | |
int main(int argc, char *argv[]) | |
{ | |
float polishStack[100]; | |
float *stackPtr; | |
float tempx, tempy; | |
float *start; |
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
#include <stdio.h> | |
void printnnl(char *); | |
void printnl(char *); | |
void printgeneric(void (*printfunc)(char *), char *str); | |
void printgeneric(void (*printfunc)(char *), char *str) | |
{ | |
(*printfunc)(str); | |
} |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
int *range(int, int); | |
int *range(int start, int end) | |
{ | |
int size = (int) fabs(end-start)+1; | |
int *values = malloc(size * sizeof(int)); |
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
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <time.h> | |
/* | |
I wrote this as a sort of challenge, I wanted to pass random words into the K&R exercise | |
that generates a hash table of key value pairs to see how quickly the hashes stack up on | |
one another. I could have easily piped random words to the input, but that's not painful | |
at all... | |
*/ |
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
#include <math.h> | |
#include <stdlib.h> | |
#include <time.h> | |
struct numbers { | |
unsigned int size; | |
int *values; | |
}; | |
struct Set { | |
const unsigned int size; | |
const int *values; |
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
/* | |
heapSort example using priority queue from Sedgewick's Algorithms in C++ | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include "numbers.h" // https://gist.github.com/911872 | |
void insert(int); | |
int hremove(void); |
OlderNewer