Newer
Older
Scratch / ubix3 / src / sys / string.c
@Christopher W. Olsen Christopher W. Olsen on 25 Oct 2019 836 bytes Scratch
/**************************************************************************************
$Id: string.c,v 1.3 2002/04/20 02:59:46 reddawg Exp $


**************************************************************************************/

#include <ubixos/keyboard.h>
#include <ubixos/video.h>

void gets(char *string) {
  unsigned char c= 0, count = 0;
  unsigned char tempstring[2];
  
  tempstring[1] = 0;
  
  while(1) {
    c = getch();
    if(c == 10) break;
    if(c == 8 && count > 0) count-=2;
    else string[count] = c;
    tempstring[0] = c;
    kprint(tempstring);
    count++;
    }
  string[count] = '\0';
  }

int kstrcmp(char *str1, char *str2) {
  while(*str1 == *str2 && *str1!=0 && *str2!=0) { str1++; str2++; }
  if(*str1 == *str2) return 0;
  if(*str1 > *str2) return 1;
  if(*str1 < *str2) return -1;
  return -1;
  }