user-0 提问: C++如果不用strcmp,而是直接两个字符串比较结果会怎样？还有关于strlen遇到\0不会停止？

回复:
user: user-1
content: 理解和讨论之前请先学会如何观察！  计算机组成原理→DOS命令→汇编语言→C语言（不包括C++）、代码书写规范→数据结构、编译原理、操作系统→计算机网络、数据库原理、正则表达式→其它语言（包括C++）、架构……  对学习编程者的忠告： 多用小脑和手，少用大脑、眼睛和嘴，会更快地学会编程！ 眼过千遍不如手过一遍！ 书看千行不如手敲一行！ 手敲千行不如单步一行！ 单步源代码千行不如单步Debug版对应汇编一行！ 单步Debug版对应汇编千行不如单步Release版对应汇编一行！ 不会单步Release版对应汇编？在你想单步Release版C/C++代码片断的前面临时加一句DebugBreak();重建所有，然后在IDE中运行。（一般人我不告诉他！）  VC调试时按Alt+8、Alt+7、Alt+6和Alt+5,打开汇编窗口、堆栈窗口、内存窗口和寄存器窗口看每句C对应的汇编、单步执行并观察相应堆栈、内存和寄存器变化，这样过一遍不就啥都明白了吗。 对VC来说，所谓‘调试时’就是编译连接通过以后，按F10或F11键单步执行一步以后的时候，或者在某行按F9设了断点后按F5执行停在该断点处的时候。 （Turbo C或Borland C用Turbo Debugger调试,Linux或Unix下用GDB调试时,看每句C对应的汇编并单步执行观察相应内存和寄存器变化。）

user: user-2
content: Get the length of a string, using the current locale or a specified locale. More secure versions of these functions are available; see strnlen, strnlen_s, strnlen_l, wcsnlen, wcsnlen_s, wcsnlen_l, _mbsnlen, _mbsnlen_l, _mbstrnlen, _mbstrnlen_l    size_t strlen(    const char *str ); size_t strlen_l(    const char *str,    _locale_t locale  ); size_t wcslen(    const wchar_t *str  ); size_t wcslen_l(    const wchar_t *str,    _locale_t locale ); size_t _mbslen(    const unsigned char *str  ); size_t _mbslen_l(    const unsigned char *str,    _locale_t locale ); size_t _mbstrlen(    const char *str ); size_t _mbstrlen_l(    const char *str,    _locale_t locale );    Collapse imageParameters str Null-terminated string.  locale Locale to use.  Collapse imageReturn Value Each of these functions returns the number of characters in str, excluding the terminal NULL. No return value is reserved to indicate an error, except for _mbstrlen, which returns -1 if the string contains an invalid multibyte character.  Collapse imageRemarks strlen interprets the string as a single-byte character string, so its return value is always equal to the number of bytes, even if the string contains multibyte characters. wcslen is a wide-character version of strlen; the argument of wcslen is a wide-character string and the count of characters is in wide (two-byte) characters. wcslen and strlen behave identically otherwise.  Security Note    These functions incur a potential threat brought about by a buffer overrun problem. Buffer overrun problems are a frequent method of system attack, resulting in an unwarranted elevation of privilege. For more information, see Avoiding Buffer Overruns.  TCHAR.H routine   _UNICODE & _MBCS not defined  _MBCS defined  _UNICODE defined   _tcslen  strlen  strlen  wcslen   _tcsclen  strlen  _mbslen  wcslen   _tcsclen_l  strlen_l  _mbslen_l  wcslen_l    _mbslen,_mbslen_l, _mbstrlenand_mbstrlen_l return the number of multibyte characters in a multibyte-character string but they do not test for multibyte-character validity. _mbstrlenand_mbstrlen_l tests for multibyte-character validity and recognizes multibyte-character sequencessetlocale, _wsetlocale. If the string passed to _mbstrlen or_mbstrlen_l contain an invalid multibyte character for the code page, it returns -1 and sets errno to EILSEQ.  The output value is affected by the setting of the LC_CTYPE category setting of the locale; see setlocale for more information. The versions of these functions without the _l suffix use the current locale for this locale-dependent behavior; the versions with the _l suffix are identical except that they use the locale parameter passed in instead. For more information, see Locale.  Collapse imageRequirements Routine  Required header   strlen  <string.h>   strlen_l  <string.h>   wcslen, wcslen_l  <string.h> or <wchar.h>   _mbslen, _mbslen_l  <mbstring.h>   _mbstrlen, _mbstrlen_l  <stdlib.h>    For additional compatibility information, see Compatibility in the Introduction.  Collapse imageExample   Copy imageCopy Code  // crt_strlen.c // Determine the length of a string. For the multi-byte character // example to work correctly, the Japanese language support for // non-Unicode programs must be enabled by the operating system.   #include <string.h> #include <locale.h>  int main() {    char* str1 = "Count.";    wchar_t* wstr1 = L"Count.";    char * mbstr1;    char * locale_string;     // strlen gives the length of single-byte character string    printf("Length of '%s' : %d\n", str1, strlen(str1) );     // wstrlen gives the length of a wide character string    wprintf(L"Length of '%s' : %d\n", wstr1, wcslen(wstr1) );     // A multibyte string: [A] [B] [C] [katakana A] [D] [\0]    // in Code Page 932. For this example to work correctly,    // the Japanese language support must be enabled by the    // operating system.    mbstr1 = "ABC" "\x83\x40" "D";     locale_string = setlocale(LC_CTYPE, "Japanese_Japan");     if (locale_string == NULL)    {       printf("Japanese locale not enabled. Exiting.\n");       exit(1);    }    else    {       printf("Locale set to %s\n", locale_string);    }     // _mbslen will recognize the Japanese multibyte character if the    // current locale used by the operating system is Japanese    printf("Length of '%s' : %d\n", mbstr1, _mbslen(mbstr1) );     // _mbstrlen will recognize the Japanese multibyte character    // since the CRT locale is set to Japanese even if the OS locale    // isnot.     printf("Length of '%s' : %d\n", mbstr1, _mbstrlen(mbstr1) );    printf("Bytes in '%s' : %d\n", mbstr1, strlen(mbstr1) );       }     Copy imageCopy Code  Length of 'Count.' : 6 Length of 'Count.' : 6 Length of 'ABCァD' : 5 Length of 'ABCァD' : 5 Bytes in 'ABCァD' : 6

user: user-2
content: if(c>tmp.c)  //比较地址呀  '\0‘的ASII值就是0

user: user-3
content: 第一个问题，两个字符串直接比较，比较的是字符串的指针; 第二个问题，你输入的\0并不是c语言里的'\0'。在c语言里，'\0'是指一个字符，其值为0，而你输入的"\0"是两个字符，值分别是\和0的asci码