string.dc
来自「Object-Oriented Programming With ANSI-C这」· DC 代码 · 共 33 行
DC
33 行
#include <stdlib.h>#include <string.h>% String ctor { struct String * self = super_ctor(String(), _self, app); const char * text = va_arg(* app, const char *); self -> text = malloc(strlen(text) + 1); assert(self -> text); strcpy((char *) self -> text, text); return self;}% String dtor {%casts free((void *) self -> text), self -> text = 0; return super_dtor(String(), self);}% String puto {%casts return fputs(self -> text, fp);}% String differ { struct String * self = cast(String(), _self); struct String * sp = cast(String(), b); return self == sp ? 0 : strcmp(self -> text, sp -> text);}%init
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?