#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define __Text "hello"
int main( ) {
int asdasd;
char * textarr = "hello" ;
char text[ ] = "hello" ;
printf ( "비교대상 : #define __Text \" hello\" , 외 스트링 \" hello\" \n " ) ;
printf ( "textarr = %s, %c\n text[] = %s, %c\n \n " , textarr, * ( textarr) , text, * text) ;
// 바교 첫번쨰
if ( textarr == "hello" ) {
printf ( "1. \" hello\" 와 textarr 는 같습니다.\n " ) ;
printf ( "주소값 : %d, %d 로 두 값은 일치 합니다.\n \n " , textarr, "hello" ) ;
}
// 비교 두번째
if ( __Text == "hello" ) {
printf ( "2. \" hello\" 와 define Text 는 같습니다.\n " ) ;
printf ( "주소값 : %d, %d\n \n " , & __Text, "hello" ) ;
}
// 비교 세번째
if ( __Text == textarr) {
printf ( "3-1. define Text 와 textarr 는 같습니다. ( 비교연산자 )\n " ) ;
printf ( "주소값 : %d, %d\n \n " , & __Text, & textarr) ;
}
// 비교 세번째 2
if ( __Text == text) {
printf ( "3-2. define Text 와 text 는 같습니다. ( 비교연산자 )\n " ) ;
printf ( "주소값 : %d, %d\n \n " , & __Text, & text) ;
} else {
printf ( "3-2. define Text 와 text 는 같지 않습니다. ( 비교연산자 )\n " ) ;
printf ( "주소값 : %d, %d\n \n " , & __Text, & text) ;
}
// 비교 네번째
if ( strcmp ( __Text, textarr) == 0 ) {
printf ( "4. __Text 와 textarr 는 같습니다. ( strcmp 비교 )\n " ) ;
printf ( "주소값 : %d, %d\n \n " , & __Text, & textarr) ;
}
// 비교 다섯번째
if ( strcmp ( text, textarr) == 0 ) {
printf ( "5. text 와 textarr 는 같습니다. ( strcmp 비교 )\n " ) ;
printf ( "주소값 : %d, %d\n \n " , & __Text, & textarr) ;
}
// 비교 여섯번째
if ( text == textarr) {
printf ( "text 와 textarr 는 같습니다.\n " ) ;
printf ( "주소값 : %d, %d\n " , & text, & textarr) ;
} else {
printf ( "6. ##### 배열 text 와 배열 textarr 는 같지 않습니다. ##### ( 비교 연산자 ) \n " ) ;
printf ( " ##### 이유 : %d, %d\n \n " , & text, & textarr) ;
}
// 비교 일곱번째
int __address = ( int ) & ( "hello" ) ;
if ( ( int ) __Text == __address) {
printf ( "7. 문자열은 해당 문자열이 저장된 주소값(숫자)를 이용한 비교를 하게 됩니다..\n \n " ) ;
}
system ( "pause" ) ;
return 0 ;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHN0cmluZy5oPgoKI2RlZmluZSBfX1RleHQgImhlbGxvIgoKaW50IG1haW4oKXsKICAgIGludCBhc2Rhc2Q7CiAgICBjaGFyICp0ZXh0YXJyID0gImhlbGxvIjsKICAgIGNoYXIgdGV4dFtdID0gImhlbGxvIjsKICAgIHByaW50Zigi67mE6rWQ64yA7IOBIDogI2RlZmluZSBfX1RleHQgXCJoZWxsb1wiLCDsmbgg7Iqk7Yq466eBIFwiaGVsbG9cIlxuIik7CiAgICBwcmludGYoInRleHRhcnIgPSAlcywgJWNcbnRleHRbXSA9ICVzLCAlY1xuXG4iLCB0ZXh0YXJyLCAqKHRleHRhcnIpLCB0ZXh0LCAqdGV4dCk7CgogICAgLy8g67CU6rWQIOyyq+uyiOyosAogICAgaWYodGV4dGFyciA9PSAiaGVsbG8iKXsKICAgICAgICBwcmludGYoIjEuIFwiaGVsbG9cIuyZgCB0ZXh0YXJyIOuKlCDqsJnsirXri4jri6QuXG4iKTsKICAgICAgICBwcmludGYoIuyjvOyGjOqwkiA6ICVkLCAlZCDroZwg65GQIOqwkuydgCDsnbzsuZgg7ZWp64uI64ukLlxuXG4iLCB0ZXh0YXJyLCAiaGVsbG8iKTsKICAgIH0KCiAgICAvLyDruYTqtZAg65GQ67KI7Ke4CiAgICBpZihfX1RleHQgPT0gImhlbGxvIil7CiAgICAgICAgcHJpbnRmKCIyLiBcImhlbGxvXCLsmYAgZGVmaW5lIFRleHQg64qUIOqwmeyKteuLiOuLpC5cbiIpOwogICAgICAgIHByaW50Zigi7KO87IaM6rCSIDogJWQsICVkXG5cbiIsICZfX1RleHQsICJoZWxsbyIpOwogICAgfQoKICAgIC8vIOu5hOq1kCDshLjrsojsp7gKICAgIGlmKF9fVGV4dCA9PSB0ZXh0YXJyKXsKICAgICAgICBwcmludGYoIjMtMS4gZGVmaW5lIFRleHQg7JmAIHRleHRhcnIg64qUIOqwmeyKteuLiOuLpC4gKCDruYTqtZDsl7DsgrDsnpAgKVxuIik7CiAgICAgICAgcHJpbnRmKCLso7zshozqsJIgOiAlZCwgJWRcblxuIiwgJl9fVGV4dCwgJnRleHRhcnIpOwogICAgfQoKICAgIC8vIOu5hOq1kCDshLjrsojsp7ggMgogICAgaWYoX19UZXh0ID09IHRleHQpewogICAgICAgIHByaW50ZigiMy0yLiBkZWZpbmUgVGV4dCDsmYAgdGV4dCDripQg6rCZ7Iq164uI64ukLiAoIOu5hOq1kOyXsOyCsOyekCApXG4iKTsKICAgICAgICBwcmludGYoIuyjvOyGjOqwkiA6ICVkLCAlZFxuXG4iLCAmX19UZXh0LCAmdGV4dCk7CiAgICB9IGVsc2UgewogICAgICAgIHByaW50ZigiMy0yLiBkZWZpbmUgVGV4dCDsmYAgdGV4dCDripQg6rCZ7KeAIOyViuyKteuLiOuLpC4gKCDruYTqtZDsl7DsgrDsnpAgKVxuIik7CiAgICAgICAgcHJpbnRmKCLso7zshozqsJIgOiAlZCwgJWRcblxuIiwgJl9fVGV4dCwgJnRleHQpOwogICAgfQoKICAgIC8vIOu5hOq1kCDrhKTrsojsp7gKICAgIGlmKHN0cmNtcChfX1RleHQsIHRleHRhcnIpID09IDApewogICAgICAgIHByaW50ZigiNC4gX19UZXh0IOyZgCB0ZXh0YXJyIOuKlCDqsJnsirXri4jri6QuICggc3RyY21wIOu5hOq1kCApXG4iKTsKICAgICAgICBwcmludGYoIuyjvOyGjOqwkiA6ICVkLCAlZFxuXG4iLCAmX19UZXh0LCAmdGV4dGFycik7CiAgICB9CgogICAgLy8g67mE6rWQIOuLpOyEr+uyiOynuAogICAgaWYoc3RyY21wKHRleHQsIHRleHRhcnIpID09IDApewogICAgICAgIHByaW50ZigiNS4gdGV4dCDsmYAgdGV4dGFyciDripQg6rCZ7Iq164uI64ukLiAoIHN0cmNtcCDruYTqtZAgKVxuIik7CiAgICAgICAgcHJpbnRmKCLso7zshozqsJIgOiAlZCwgJWRcblxuIiwgJl9fVGV4dCwgJnRleHRhcnIpOwogICAgfQoKICAgIC8vIOu5hOq1kCDsl6zshK/rsojsp7gKICAgIGlmKHRleHQgPT0gdGV4dGFycil7CiAgICAgICAgcHJpbnRmKCJ0ZXh0IOyZgCB0ZXh0YXJyIOuKlCDqsJnsirXri4jri6QuXG4iKTsKICAgICAgICBwcmludGYoIuyjvOyGjOqwkiA6ICVkLCAlZFxuIiwgJnRleHQsICZ0ZXh0YXJyKTsKICAgIH0gZWxzZSB7CiAgICAgICAgcHJpbnRmKCI2LiAjIyMjIyDrsLDsl7QgdGV4dCDsmYAg67Cw7Je0IHRleHRhcnIg64qUIOqwmeyngCDslYrsirXri4jri6QuICMjIyMjICgg67mE6rWQIOyXsOyCsOyekCApIFxuIik7CiAgICAgICAgcHJpbnRmKCIgICAjIyMjIyDsnbTsnKAgOiAlZCwgJWRcblxuIiwgJnRleHQsICZ0ZXh0YXJyKTsKICAgIH0KCiAgICAvLyDruYTqtZAg7J286rOx67KI7Ke4CiAgICBpbnQgX19hZGRyZXNzID0gKGludCkmKCJoZWxsbyIpOwogICAgaWYoKGludClfX1RleHQgPT0gX19hZGRyZXNzKXsKICAgICAgICBwcmludGYoIjcuIOusuOyekOyXtOydgCDtlbTri7kg66y47J6Q7Je07J20IOyggOyepeuQnCDso7zshozqsJIo7Iir7J6QKeulvCDsnbTsmqntlZwg67mE6rWQ66W8IO2VmOqyjCDrkKnri4jri6QuLlxuXG4iKTsKICAgIH0KCiAgICBzeXN0ZW0oInBhdXNlIik7CiAgICByZXR1cm4gMDsKfQo=