文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>c/c++ function

c/c++ function

时间:2007-05-23  来源:我爱spring

strstr:

Syntax:
#include <string.h>
char *strstr( const char *str1, const char *str2 );

The function strstr() returns a pointer to the first occurrence of str2 in str1, or NULL if no match is found. If the length of str2 is zero, then strstr() will simply return str1.

For example, the following code checks for the existence of one string within another string:

 char* str1 = "this is a string of characters";
char* str2 = "a string";
char* result = strstr( str1, str2 );
if( result == NULL ) printf( "Could not find '%s' in '%s'\n", str2, str1 );
else printf( "Found a substring: '%s'\n", result );

When run, the above code displays this output:

 Found a substring: 'a string of chara

memchr: Syntax: #include <string.h>
void *memchr( const void *buffer, int ch, size_t count );

The memchr() function looks for the first occurrence of ch within count characters in the array pointed to by buffer. The return value points to the location of the first occurrence of ch, or NULL if ch isn't found. For example:

char names[] = "Alan Bob Chris X Dave";
if( memchr(names,'X',strlen(names)) == NULL )
    printf( "Didn't find an X\n" );
else
    printf( "Found an X\n" );

memcmp:
Syntax:
 #include <string.h>
int memcmp( const void *buffer1, const void *buffer2, size_t count );

The function memcmp() compares the first count characters of buffer1 and buffer2. The return values are as follows:

Value Explanation
less than 0 buffer1 is less than buffer2
equal to 0 buffer1 is equal to buffer2
greater than 0 buffer1 is greater than buffer2


 Standard C String:
atof converts a string to a double
atoi converts a string to an integer
atol converts a string to a long
isalnum true if a character is alphanumeric
isalpha true if a character is alphabetic
iscntrl true if a character is a control character
isdigit true if a character is a digit
isgraph true if a character is a graphical character
islower true if a character is lowercase
isprint true if a character is a printing character
ispunct true if a character is punctuation
isspace true if a character is a space character
isupper true if a character is an uppercase character
isxdigit true if a character is a hexidecimal character
memchr searches an array for the first occurance of a character
memcmp compares two buffers
memcpy copies one buffer to another
memmove moves one buffer to another
memset fills a buffer with a character
strcat concatenates two strings
strchr finds the first occurance of a character in a string
strcmp compares two strings
strcoll compares two strings in accordance to the current locale
strcpy copies one string to another
strcspn searches one string for any characters in another
strerror returns a text version of a given error code
strlen returns the length of a given string
strncat concatenates a certain amount of characters of two strings
strncmp compares a certain amount of characters of two strings
strncpy copies a certain amount of characters from one string to another
strpbrk finds the first location of any character in one string, in another string
strrchr finds the last occurance of a character in a string
strspn returns the length of a substring of characters of a string
strstr finds the first occurance of a substring of characters
strtod converts a string to a double
strtok finds the next token in a string
strtol converts a string to a long
strtoul converts a string to an unsigned long
strxfrm converts a substring so that it can be used by string comparison functions
tolower converts a character to lowercase
toupper converts a character to uppercase

C/C++ Reference:

http://www.cppreference.com/index.html



相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载