-
Notifications
You must be signed in to change notification settings - Fork 0
csUtility
CoSprite's miscellaneous utility functions. Most will not see too much use, but if you are going to use them, they will prove helpful. As well, defines the standard CoSprite defines like the bool type, boolToString, and NULL (if these things are not already defined).
int randInt(int low, int high, bool inclusive)
Gives you a random integer from low to high. You can set whether or not bounds are inclusive or not.
int digits(int num)
Given an integer, it returns out how many digits that integer takes up.
void* freeThisMem(void* x)
Note: Nothing appears to be wrong with this function, but usage isn't advised. It just free()s your memory then returns NULL so you can do myMem = freeThisMem(myMem); one smooth line for free()ing, but at the same time you're old enough to set your own memory to NULL (or choose not to).
char* removeNewline(char* stuff, char replacement, int maxLength)
Replaces newline characters with replacement, spitting out a string of at most maxLength. Returns the same char* as inputted in stuff. Both your original string and the output will be the correct modified string.
double getDistance(double x1, double y1, double x2, double y2)
Does the distance formula (Pythagorean Formula) calculation between two points.