Hsue66 / Algo

0 stars 0 forks source link

str #15

Open Hsue66 opened 4 years ago

Hsue66 commented 4 years ago

/*#include using namespace std;

int ztrlen(char str) { int c = 0; while (str++) c++; return c; }

void ztrcpy(char dst, char src) { while (dst++ = src++); }

int ztrcmp(char s1, chars2) { int c = 0; while (s1[c] != '\0') { if (s1[c] != s2[c]) break; c++; } return s1[c] - s2[c]; }

int main() { char arr[6] = "hello"; cout << ztrlen(arr) << endl; char arr2[6]; ztrcpy(arr2, arr); cout << arr2 << endl; cout << ztrcmp(arr, arr2) << endl; cout << ztrcmp(arr, (char)"hel") << endl; cout << ztrcmp((char)"hel", arr) << endl; } */