git.y1.nz

gbdk-2020

GameBoy Development Kit
download: https://git.y1.nz/archives/gbdk.tar.gz
README | Files | Log | Refs | LICENSE

gbdk-lib/examples/cross-platform/libc_string/src/libc_string.c

      1 //
      2 // libc_string.c
      3 // Simple test of string functions in C library string.h
      4 //
      5 #include <stdio.h>
      6 #include <string.h>
      7 
      8 #include <gbdk/platform.h>
      9 #include <gbdk/font.h>
     10 #include <gbdk/console.h>
     11 
     12 void main(void)
     13 {
     14     font_t ibm_font;
     15 
     16     // init the font system to use IBM font
     17     font_init();
     18     ibm_font = font_load(font_ibm);
     19     font_set(ibm_font);
     20 
     21     // Test strlen
     22     printf("strlen(gbdk) -> %d\n", strlen("gbdk"));
     23     // Test strcmp / strncmp
     24     printf("strcmp(gbdk,gbdk)\n-> %d\n", strcmp("gbdk", "gbdk"));
     25     printf("strcmp(gbdk,ggdk)\n-> %d\n", strcmp("gbdk", "ggdk"));
     26     printf("strcmp(ggdk,gbdk)\n-> %d\n", strcmp("ggdk", "gbdk"));
     27     printf("strncmp(gbdk,gbc,2)\n-> %d\n", strncmp("gbdk", "gbc", 2));
     28     // Test strcpy
     29     {
     30         char dst[4] = "dst";
     31         const char* src = "src";
     32         strcpy(dst, src);
     33         printf("strcpy(dst,src)\n-> %s\n", dst);
     34     }
     35     // Test strncpy
     36     {
     37         char dst[4] = "dst";
     38         const char* src = "src";
     39         strncpy(dst, src, 2);
     40         printf("strncpy(dst,src,2)\n-> %s\n", dst);
     41     }
     42     // Test strcat/strncat
     43     {
     44         char dst[9] = "gbdk";
     45         char dst2[9] = "gbdk";
     46         printf("strcat(gbdk,2020)\n-> %s\n", strcat(dst, "2020"));
     47         printf("strncat(gbdk,lib,2)\n-> %s\n", strncat(dst2, "lib",2));
     48     }
     49 }

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.