Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************
- ** STRING.H **
- ******************************/
- strcmp(char *pa, char *pb) {
- while (*pa && *pb && *pa == *pb)
- ++pa, ++pb;
- return *pa - *pb;
- }
- strlen(char *str) {
- int pos;
- pos = str;
- while (*str++) ;
- return (str - pos - 1);
- }
- strcpy(char *dst, char *src) {
- int *d;
- d = dst;
- while (*d++ = *src++) ;
- return dst;
- }
- strncpy(char *s1, char *s2, int n) {
- int *os1;
- os1 = s1;
- while (n-- && (*s1++ = *s2++)) ;
- if (n != 0) { *s1 = 0; }
- return os1;
- }
- strcat(char *dst, char *src) {
- int save;
- save = dst;
- for (; *dst; ++dst);
- while (*dst++ = *src++) ;
- return (save);
- }
- strchr(char *str, char chr) {
- int *p;
- for(p = str; *p != 0; ++p) {
- if (*p == chr)
- return p;
- }
- return 0;
- }
- strrev(char *szT) {
- if (!szT)
- return "";
- int i, t, k, j, ch;
- i = strlen(szT);
- t = !(i%2)? 1 : 0;
- for(j = i - 1, k = 0; j > (i/2 - t); j--) {
- ch = szT[j];
- szT[j] = szT[k];
- szT[k++] = ch;
- }
- return szT;
- }
- /******************************
- ** STDIO.H **
- ******************************/
- char *ccp = 0x7600;
- int *kbf = 0x75ff;
- clrscr() {
- char *i;
- i = 0x7600;
- while (i < 0x7800) {
- *i++ = 0;
- }
- }
- gotoxy(int x, int y) {
- ccp = 0x7600 + (x + y * 32);
- }
- putc(char chr) {
- if (chr == 13) {
- ccp /= 32;
- ccp *= 32;
- } else if (chr == 10) {
- ccp += 32;
- } else {
- *ccp++ = chr | 0x0f00;
- }
- }
- puts(char *ptr) {
- while (*ptr) {
- putc(*ptr++);
- }
- }
- putd(int num) {
- int temp[5], i;
- i = 0;
- do {
- temp[i++] = num % 10 + 48;
- num /= 10;
- } while (num);
- for(--i; i != 0xffff; --i) {
- putc(temp[i]);
- }
- }
- putx(int xnm) {
- int temp[4], i;
- i = 3;
- do {
- int mod;
- mod = xnm % 16;
- mod += mod < 10 ? 48 : 55;
- temp[i--] = mod;
- xnm /= 16;
- } while (xnm);
- for(;i<3;) {
- putc(temp[++i]);
- }
- }
- printf(char *fmt) {
- int off, len;
- off = 1;
- len = strlen(fmt);
- int i;
- for(i = 0; i < len; i++) {
- if (fmt[i] == 37) {
- if (fmt[i + 1] == 100)
- { putd(*(&fmt + off++)); ++i; }
- if (fmt[i + 1] == 115)
- { puts(*(&fmt + off++)); ++i; }
- if (fmt[i + 1] == 120)
- { putx(*(&fmt + off++)); ++i; }
- continue;
- }
- if (fmt[i] == 92) {
- if (fmt[i + 1] == 110)
- { putc(13); putc(10); ++i; }
- continue;
- }
- putc(fmt[i]);
- }
- }
- kbhit() {
- int tmp;
- return (tmp = *kbf) ? *kbf = 0, tmp : 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement