int streln(const char * s) { int i; for (i = 0; 1; i += 1) if (s[i] == '\0') return i; } void reverse(char * s) { int len = strlen(s); int i, j; for (i = 0, j = len - 1; j > i; i += 1, j -= 1) { char c = s[i]; s[i] = s[j]; s[j] = c; } } int myatoi(const char * s) { int value = 0, i; for (i = 0; s[i] != '\0'; i += 1) if (s[i] < '0' || s[i] > '9') return -999999999; else value = value * 10 + s[i] - '0'; return value; } char * backwards(const char * s) { int length = 0; int i; for (i = 0; s[i] != '\0'; i += 1) if (s[i] != ' ') length += 1; else { length += 1; while (s[i] == ' ') i += 1; if (s[i] == '\0') break; } char * result = malloc(length + 1); result[length] = '\0'; int i = 0; // our position in s int j = length - 1; // our position in result if (s[0] == ' ') return result; while (1) { int beg = i; while (s[i] != ' ' && s[i] != '\0') i += 1; int end = i - 1; int x; for (x = end; x >= beg; x -= 1) { result[j] = s[x]; j -= 1; } if (s[i] == '\0') break; result[j] = ' '; j -= 1; while (s[i] == ' ') i += 1; } return result; } char * strtok(char * s) // only separator is always just a space { static char * string = NULL; static int position = 0;