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
#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 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
#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 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
#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 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
#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 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
#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 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
#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 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
#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) | |
{ |
NewerOlder