¸ðµç ÇÁ·Î±×·¥µéÀº Download mychar ·Î ºÎÅÍ ÇϳªÀÇ tar.gz ÈÀÏ·Î ´Ù¿î·Îµå ¹ÞÀ» ¼ö ÀÖ´Ù. ÀÌ ÈÀÏÀ» ¾òÀ¸·Á¸é À¥ºê¶ó¿ìÀú¿¡¼ 'Text' ŸÀÔÀ¸·Î ÀúÀåÀ» ÇÏ¸é µÈ´Ù.
//***************************************************************** //ÀúÀÛ±ÇÀº GNU/GPL ÀÌÁö¸¸ Ãß°¡·Î ¸ðµç º¹Á¦º»¿¡ ÀúÀÚÀÇ À̸§°ú À̸ÞÀÏÀ» //Æ÷ÇÔ½ÃÄÑÁÖ¾î¾ß ÇÑ´Ù. //ÀúÀÚ: Al Dev À̸ÞÀÏ: alavoor@yahoo.com //***************************************************************** // ÄÄÆÄÀÏ ÇÏ·Á¸é( libmychar.a°¡ ÇöÀç µð·ºÅ丮¿¡ ÀÖ´Ù°í // °¡Á¤ÇÏ°í ) // g++ example_mychar.cpp -L. -lmychar #include <stdlib.h> // for putenv #include "mychar.h" ///////////////////////////////////////////////// //mychar »ç¿ë ¿¹Á¦ ÇÁ·Î±×·¥ ///////////////////////////////////////////////// int main(int argc, char **argv) { char p_name[1024]; sprintf(p_name, "PROGRAM_NAME=%s", argv[0]); putenv(p_name); print_total_memsize(); // in the beginning mychar aa, bb; //bb.str_cpy(" bbSTRing "); bb = " bbSTRing "; //+ ¿¬»êÀÚ Å×½ºÆ®Çϱâ //aa + " rhs "; // ¿©±â¼´Â ¾î¶² Ãâ·Âµµ °®Áö ¾Ê°Ô µÉ°ÍÀÌ´Ù !! //¹Ýµå½Ã ´ÙÀ½ÁÙ¿¡ ³ª¿À´Â °Í ó·³ Á÷Á¢ fprintf ¸¦ »ç¿ëÇØ¾ß ÇÑ´Ù. fprintf(stdout, "\n0) aa.val is :%sEOF\n", (aa + " my rhs " ).val); //=¿¬»êÀÚ Å×½ºÆ®Çϱâ aa = " lhs " ; fprintf(stdout, "0-1) With operator= aa.val is :%sEOF\n", aa.val); //+ ¿¬»êÀÚ Å×½ºÆ® Çϱâ //aa + " rhs "; // ¿©±â¼´Â ¾î¶² Ãâ·Âµµ °®Áö ¾Ê°Ô µÉ°ÍÀÌ´Ù !! //¹Ýµå½Ã ´ÙÀ½ÁÙ¿¡ ³ª¿À´Â °Í ó·³ Á÷Á¢ fprintf ¸¦ »ç¿ëÇØ¾ß ÇÑ´Ù. fprintf(stdout, "\n0) With lsh operator+, aa.val is :%sEOF\n", (" my lhs " + aa ).val); //aa.str_cpy(bb.val); aa = bb; aa.to_upper(); fprintf(stdout, "1) aa.val is :%sEOF\n", aa.val); aa = bb; aa.to_lower(); fprintf(stdout, "2) aa.val is :%sEOF\n", aa.val); aa = bb; aa.ltrim(); fprintf(stdout, "3) aa.val is :%sEOF\n", aa.val); aa = bb; aa.rtrim(); fprintf(stdout, "4) aa.val is :%sEOF\n", aa.val); aa = bb; aa.trim(); fprintf(stdout, "5) aa.val is :%sEOF\n", aa.val); aa = bb; aa = aa + " testing newlines \n\n\n\n"; aa.chop(); fprintf(stdout, "5-1) aa.val is :%sEOF\n", aa.val); aa = bb; aa = aa + " rhs "; fprintf(stdout, "6) aa.val is :%sEOF\n", aa.val); aa = bb; aa = " lhs " + aa; fprintf(stdout, "7) aa.val is :%sEOF\n", aa.val); // ¼ýÀÚ ´õÇϱ⠿¹Á¦ //aa = (mychar) 9989 + "kkk" + 33 ; aa = 9999; fprintf(stdout, "7-1) aa.val is :%sEOF\n", aa.val); aa = bb; aa = " lhs " + aa + " rhs " + " 9989 " + " 33 "; fprintf(stdout, "8) aa.val is :%sEOF\n", aa.val); aa = " AA value "; aa = bb + "alkja " + " 99djd " ; fprintf(stdout, "9) aa.val is :%sEOF\n", aa.val); aa = " AA value "; aa = (mychar) "alkja " + " 99djd " ; fprintf(stdout, "10) aa.val is :%sEOF\n", aa.val); aa = " AA value "; aa += (mychar) " al dev test kkk... " + " al2 slkj" + " al3333 "; fprintf(stdout, "11) aa.val is :%sEOF\n", aa.val); aa = " AA value "; aa = aa + " add aa " + aa + aa + aa + " 1111 " + " 2222 " + aa + aa + aa + " 3333 "; fprintf(stdout, "12) aa.val is :%sEOF\n", aa.val); aa = "12345678"; aa.reverse(); fprintf(stdout, "13) aa.val is :%sEOF\n", aa.val); aa = " AA value "; aa = aa + " add aa " + aa + 1111 +" "+ 2222 + " " + 3.344 + aa; fprintf(stdout, "14) aa.val is :%sEOF\n", aa.val); aa.roundd(123456.0123456789012345, 13); fprintf(stdout, "15) double aa.val is :%sEOF\n", aa.val); aa.roundf(123456.0123456789, 13); fprintf(stdout, "16) float aa.val is :%sEOF\n", aa.val); // Test equal to operators aa = " AA value "; mychar cc(" AA value "); if (aa == cc) fprintf(stdout, "\naa=%s and cc=%s are equal!!\n", aa.val, cc.val); else fprintf(stdout, "\naa=%s and cc=%s are NOT equal!!\n", aa.val, cc.val); cc = "CC"; if (aa == cc) fprintf(stdout, "\naa=%s and cc=%s are equal!!\n", aa.val, cc.val); else fprintf(stdout, "\naa=%s and cc=%s are NOT equal!!\n", aa.val, cc.val); if (aa == " AA value ") fprintf(stdout, "\naa=%s and string are equal!!\n", aa.val); else fprintf(stdout, "\naa=%s and string are NOT equal!!\n", aa.val); if (aa == " AA valuexxx ") fprintf(stdout, "\naa=%s and string are equal!!\n", aa.val); else fprintf(stdout, "\naa=%s and string are NOT equal!!\n", aa.val); //aa.val ¸¦ 'char *' º¯¼öó·³ ÇÁ·Î±×·¥¿¡¼ »ç¿ëÇÒ ¼ö ÀÖ´Ù!! fprintf(stdout, "\n "); for (unsigned long tmpii = 0; tmpii < aa.length(); tmpii++) { fprintf(stdout, "aa.val[%ld]=%c ", tmpii, aa.val[tmpii]); } fprintf(stdout, "\n"); //'char *' val ...¿¡ Æ÷ÀÎÅÍ »ç¿ëÇϱâ fprintf(stdout, "\n "); for (char *tmpcc = aa.val; *tmpcc != 0; tmpcc++) { // MUST use temporary var tmpcc !! See note above. fprintf(stdout, "aa.val=%c ", *tmpcc); } fprintf(stdout, "\n"); print_total_memsize(); // in the end exit(0); }