void Terminal_scroll() { u16 blank = ' ' | ((((Terminal_backgroundColor | (Terminal_backgroundBright << 3)) << 4) | ((Terminal_foregroundColor | (Terminal_foregroundBright << 3)) & 0x0F)) << 8); if (Terminal_cursor.y >= TTY_ROWS) { /* Move everything up one line */ u32 position = Terminal_cursor.y - TTY_ROWS + 1; String_copy((u8*) Terminal_ram, (u8*) (Terminal_ram + position * TTY_COLS), (TTY_ROWS - position) * TTY_COLS * 2); /* Blank the last line */ String_setWord(Terminal_ram + (TTY_ROWS - position) * TTY_COLS, blank, TTY_COLS); Terminal_cursor.y = TTY_ROWS - 1; } }
int main() { String * myKey, *myKey2, *myValue, *tmpString; List * keys; ListIterator * iterator; HashTable * table = HashTable_create(500); myKey = String_create("Mia"); myKey2 = String_create("Russell"); myValue = String_create("shrug"); HashTable_setValue(table, myKey, String_copy(myValue)); HashTable_setValue(table, myKey2, String_copy(myValue)); String_destroy(myValue); keys = HashTable_getKeys(table); iterator = ListIterator_create(keys); tmpString = ListIterator_seekToFirst(iterator); while(tmpString != NULL) { myValue = HashTable_removeValue(table, tmpString); printf("Removed -> %s\n", String_c(myValue)); String_destroy(myValue); tmpString = ListIterator_seekToFirst(iterator); } ListIterator_destroy(iterator); String_destroy(myKey); String_destroy(myKey2); HashTable_destroy(table); return 0; }
int main() { String s1 = String_new("abcd"); String s2 = String_new("xyz"); String s3 = String_concat(s1, s2); String_free(s1); String s4 = String_copy(s2); String_free(s2); char *c1 = String_toCharArray(s3); char *c2 = String_toCharArray(s4); if (String_length(s3) > String_length(s4)) printf("%s is longer than %s\n", c1, c2); else printf("%s is longer than %s\n", c2, c1); if (String_compare(s3, s4) > 0) printf("%s is greater than %s\n", c1, c2); else if (String_compare(s3, s4) < 0) printf("%s is greater than %s\n", c2, c1); else printf("%s and %s are the same\n", c2, c1); }