第1个回答 2018-02-12
用sizeof函数,得到字节大小,然后看这个数组什么类型的,比如double类型,一个就占16位,就是2字节,就算出来了。
c++直接有length函数,可以直接给出长度,c没有
满意请采纳,如有疑问请追问
第2个回答 推荐于2016-06-09
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
/////////////////////////////////////////////////////////
CString::GetLength
int GetLength( ) const;
Return Value
A count of the bytes in the string.
Remarks
Call this member function to get a count of the bytes in this CString object. The count does not include a null terminator.
For multibyte character sets (MBCS), GetLength counts each 8-bit character; that is, a lead and trail byte in one multibyte character are counted as two bytes.
Example
The following example demonstrates the use of CString::GetLength.
// example for CString::GetLength
CString s( "abcdef" );
ASSERT( s.GetLength() == 6 );本回答被提问者采纳
第3个回答 2006-09-27
int strlen(const char *s) ,s为待求长度的字符串指针,头文件string.h
第4个回答 2006-09-28
头文件string.h
strlen(char str[]) ,str[]为待求长度的字符串