string.c
来自「国产CPU-龙芯(loongson)BIOS源代码」· C语言 代码 · 共 63 行
C
63 行
/* Simple string functions */#include <stdio.h>int strlen(char *str){ int i = 0; while(str[i++] != NULL) { if (i>0x100000) { WARNING("String too large\n"); panic("die\n"); } } return i;}void strcpy(char *to, char *from){ int i,j; int count = 0; i = strlen(to); j = strlen(from); for (count = 0; count < j; count++) { to[count] = from[count]; i--; if (i == 0) break; } if (i) { for (j = count; j < i+count; j++) to[j] = 0; }}int strcmp(char *to, char *from){ int i,j; int count = 0; i = strlen(to); j = strlen(from); for (count=0;count<j;count++) { i--; if (to[count] == from[count]) continue; else { if (to[count] > from[count]) return 1; else return -1; } if (i == 0) return -1; } if (i) return 1; return 0;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?