传统的错误处理机制:
#include<iostream> using namespace std; //传统的处理机制 int my_strcopy(char* from, char* to) { if (from == NULL) return 1; if (to == NULL) return 2; //拷贝场景检查 if (*from == 'a') return 3; while (*from != '