我想知道一些函数的实现??

xiaofk 2001-09-19 10:44:40
我想知道一些函数如strlen等的实现,那里有这方面的文档。
...全文
136 12 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaofk 2001-09-21
  • 打赏
  • 举报
回复
wang_rui_bing_(啊福) 我已经收到。
谢谢各位!
wang_rui_bing_ 2001-09-20
  • 打赏
  • 举报
回复
我已經發過去了,收到了嗎?
reinly 2001-09-20
  • 打赏
  • 举报
回复
thank you

neak@163.com
jackeyjia 2001-09-20
  • 打赏
  • 举报
回复
strlen, wcslen, _mbslen, _mbstrlen
Get the length of a string.

size_t strlen( const char *string );

size_t wcslen( const wchar_t *string );

size_t _mbslen( const unsigned char *string );

size_t _mbstrlen( const char *string );

Routine Required Header Compatibility
strlen <string.h> ANSI, Win 95, Win NT
wcslen <string.h> or <wchar.h> ANSI, Win 95, Win NT
_mbslen <mbstring.h> Win 95, Win NT
_mbstrlen <stdlib.h> Win 95, Win NT


For additional compatibility information, see Compatibility in the Introduction.

Libraries

LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version


Return Value

Each of these functions returns the number of characters in string, excluding the terminal NULL. No return value is reserved to indicate an error.

Parameter

string

Null-terminated string

Remarks

Each of these functions returns the number of characters in string, not including the terminating null character. wcslen is a wide-character version of strlen; the argument of wcslen is a wide-character string. wcslen and strlen behave identically otherwise.

Generic-Text Routine Mappings

TCHAR.H Routine _UNICODE & _MBCS Not Defined _MBCS Defined _UNICODE Defined
_tcslen strlen strlen wcslen
_tcsclen strlen _mbslen wcslen


_mbslen and _mbstrlen return the number of multibyte characters in a multibyte-character string. _mbslen recognizes multibyte-character sequences according to the multibyte code page currently in use; it does not test for multibyte-character validity. _mbstrlen tests for multibyte-character validity and recognizes multibyte-character sequences according to the LC_CTYPE category setting of the current locale. For more information about the LC_CTYPE category, see setlocale.

Example

/* STRLEN.C */

#include <string.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>

void main( void )
{
char buffer[61] = "How long am I?";
int len;
len = strlen( buffer );
printf( "'%s' is %d characters long\n", buffer, len );
}


Output

'How long am I?' is 14 characters long

xiaofk 2001-09-20
  • 打赏
  • 举报
回复
我的email 是xiaofk@263.net !
yyhyan 2001-09-19
  • 打赏
  • 举报
回复
gz
zhangjingjing 2001-09-19
  • 打赏
  • 举报
回复
要是我用C/C++写的话,可能大致如下(没加其它检测信息)
int strlen(char *s)
{
for(int i=0;;i++)
if(s[i]==NULL)
break;
return i;
}

TopCat 2001-09-19
  • 打赏
  • 举报
回复
去看看K&R 的C语言书籍,上面好像就介绍的。
yyhyan 2001-09-19
  • 打赏
  • 举报
回复
多谢!!!!!!,我要
yyhyan@elong.com
wang_rui_bing_ 2001-09-19
  • 打赏
  • 举报
回复
我有這方面的原碼,是我們公司自己開發產品的一部分,要可以給你發過去
cnss 2001-09-19
  • 打赏
  • 举报
回复
VC有c runtime源码,只要你装了

在crt\src目录下
oujinliang 2001-09-19
  • 打赏
  • 举报
回复
int strlen(char *s)
{
for(int i=0;*s++!=NULL;i++)
;
return i;
}
只要理解C 中字符串在内存中是如何实现的,以及函数调用的规则,就可以。

70,023

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧