ÇÁ·Î±×·¡¹Ö

 3206, 5/161 ȸ¿ø°¡ÀÔ  ·Î±×ÀΠ 
   hkpco
   [re] [Áú¹®] return 1; <=== ÀÌ°í

http://www.hackerschool.org/HS_Boards/zboard.php?id=QNA_programming&no=104 [º¹»ç]


½±°Ô ¼³¸íÇÏÀÚ¸é

strcmp ¶ó´Â ÇÔ¼ö¸¦ °¡Á¤Çϸé

a == b À̸é 0 À» ¸®ÅÏ

a  < b À̸é À½¼ö¸¦ ¸®ÅÏ

a  > b ÀÌ¸é ¾ç¼ö¸¦ ¸®ÅÏ

ÀÌ·±½Ä À¸·Î ¸®ÅÏÀ» ÇÏ¿© ÁÝ´Ï´Ù.

±×·³ ¿ì¸®´Â

if( (strcmp( "aaa" , "aaa" ) == 0 )
{
      printf( "°°³×¿ä\n" );
}

ÀÌ·±½ÄÀ¸·Î strcmp ÇÔ¼ö¸¦ »ç¿ëÇÕ´Ï´Ù.

strcmp ÇÔ¼öÀÇ ³»ºÎ¸¦ º¸¸é

Àú·±½ÄÀ¸·Î ºñ±³ÇÏ°í ³ª¼­ °°À¸¸é 0 ÀÌ·±½ÄÀ¸·Î ¸®ÅÏÀ» ÇÕ´Ï´Ù.

Á¤¸» ±×·¯³Ä±¸¿ä?

Àú¹ø¿¡ ±¸ÇöÇÑ°Ô Àִµ¥ Âü°íÇϼ¼¿ä

- strcmp.c -

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>

int M_strcmp( const char *a , const char *b );

int main( void )
{
        char a[] = "abcde\n";
        char b[] = "abxaa\n";
        char c[] = "asf\n";
        char d[] = "eqwefawf\n";

printf("%d\n",M_strcmp( a , b ));
printf("%d\n",M_strcmp( a , c ));
printf("%d\n",M_strcmp( a , d ));
}

int M_strcmp( const char *a , const char *b )
{
        unsigned int re1;
        signed int re2;

        int al = strlen( a );
        int bl = strlen( b );

        for( ; *a ; a++ , b++ )
        {
                if( *a > *b ) return re1;
                else if( *a < *b ) return re2;
                else if( *a == *b ) continue;
        }

        if( al > bl )
                return re1;

        else if( al < bl )
                return re2;

        else if( al == bl )
                return 0;

}

- End Of Source -

  Hit : 3817     Date : 2003/09/27 12:17



    
3126     [re] ¸®´ª½ºÈ¯°æ¿¡¼­ c++ ¿î¿µÇÒ·Á¸é?     hkpco
09/22 3438
3125     [re] C ¾ð¾î ¿¡¼­ ÄÄÆÄÀÏ·¯ ÇÒ¶§ ±Ã±ÝÇÑ°Ô ÀÖ¾î¿ä ^[1]     hkpco
09/22 3906
3124     [re] Áú¹® ÇÑ°³ ´õ ÀÖ¾î¿ä ^^;;[1]     hkpco
09/22 3796
3123     [re] Áú¹®ÀÌ¿ä.[1]     hkpco
09/22 3632
3122   Æ÷ÀÎÅ͸¦ ½±°Ô¼³¸íÇØÁÖ¼¼¿°[6]     ¤Ñ.¤Ñ
09/22 3932
3121   Áú¹®ÀÌ¿±[1]     zerolhs
09/22 4271
3120     [re] Áú¹®ÀÌ¿±     viniru-pudae
09/22 3781
3119   ÀÌ°Å Âü...-_-[3]     sagelord
09/23 4471
3118   ¿À´ÃÀº Áú¹®ÀÌ Á» ¸¹³×¿ä^^;     sagelord
09/23 4460
3117     [re] ¿À´ÃÀº Áú¹®ÀÌ Á» ¸¹³×¿ä^^;[1]     »þ¸£
09/23 4087
3116   [Áú¹®]½©ÇÁ·Î±×·¡¹Ö....[2]     Keres
09/24 3772
3115   ¹öºí¼ÒÆ®°¡¹¹ÁÒ??     zerolhs
09/24 4368
3114     [re] ¹öºí¼ÒÆ®°¡¹¹ÁÒ??[4]     LinuxCom
09/25 3744
3113   ÁÖÇÁ·Î±×·¥°ú ºÎÇÁ·Î±×·¥[2]     cert_999
09/25 4276
3112   ÆÄÀÏ ÀÔÃâ·Â¿¡ ´ëÇØ[2]     3cushion
09/25 4451
3111   [Áú¹®] return 1; <=== ÀÌ°í[1]     o-0_o-0
09/26 3461
3110     [re] [Áú¹®] return 1; <=== ÀÌ°í     bboyhwandori
09/27 3679
    [re] [Áú¹®] return 1; <=== ÀÌ°í     hkpco
09/27 3816
3108   °ÔÀÓ ÇÁ·Î±×·¡¹ÖÀ» ÇÒ·Á¸é ¾î¶»°ÔÇÏÁÒ?[1]     tjgmltjd
09/27 3896
3107   ÄÄÆÄÀÏÀÌ ¾ÈµË´Ï´Ù.[4]     hansu9
09/27 4019
[1][2][3][4] 5 [6][7][8][9][10]..[161]

Copyright 1999-2024 Zeroboard / skin by Hackerschool.org / Secure Patch by Hackerschool.org