// STRFUNC.cpp : 콘솔 응용 프로그램에 대한 진입점을 정의합니다. // #include "stdafx.h" #include <iostream> using namespace std; int mystrlen(char* txt) { int count = 0; while( *(unsigned char *) txt) { ++txt; ++count; } return count; } int mymystrcmp(const char *src, const char *dest) { int ret = 0; while (!(ret = *(unsigned char *) src - *(unsigned char *) dest) && *dest) { ++src, ++dest; } if (ret < 0) ret = -1; else if (ret > 0) ret = 1 ; return ret; } class CLASSA { public: int a; }; int _tmain(int argc, _TCHAR* argv[]) { char* txt0 = "1234abcaABCD"; char* txt1 = "1234abcaABCD"; char* txt2 = "1234abcf"; char* txt3 = "1234,abcd,ABCD "; char* txt4 = "1234abcaABCDc"; const int a = 0; int max = strlen(txt0); cout << max << endl; max = mystrlen(txt0); cout << max << endl; int cmp = strcmp(txt0, txt1); cout << "같다 " << cmp << endl; cmp = strcmp(txt0, txt2); cout << "짧다 " << cmp << endl; cmp = strcmp(txt0, txt3); cout << "길다 " << cmp << endl; cmp = strcmp(txt0, txt4); cout << "길이는 같다 " << cmp << endl; cmp = mymystrcmp(txt0, txt1); cout << "같다 " << cmp << endl; cmp = mymystrcmp(txt0, txt2); cout << "짧다 " << cmp << endl; cmp = mymystrcmp(txt0, txt3); cout << "길다 " << cmp << endl; cmp = mymystrcmp(txt0, txt4); cout << "길이는 같다 " << cmp << endl; return 0; } |