main() { char *str = "漢字abcあいう123"; printf("文字数:%d\n", strlen(str)); }
main() { char *str = "漢字abcあいう123"; int i1; int count = 0; for(i1 =0;;){ if(str[i1] == '\0') break; if(_ismbblead(str[i1])){ if(str[i1+1] == '\0'){ count++; break; } count++; i1 += 2; continue; } count++; i1++; } printf("文字数:%d\n", count); }
C:\StudyC\MyProg>expr _mbslen("漢字abcあいう123") 11 0xb C:\StudyC\MyProg>expr strlen("漢字abcあいう123") 16 0x10