⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 st

📁 Algorithms for Image Processing and Computer Vision Source Code
💻
📖 第 1 页 / 共 2 页
字号:
This function compares the two strings, disregarding case.

@subheading Return Value

Zero if they're the same, nonzero if different, the sign indicates
"order". 

@subheading Example

@example
if (stricmp(arg, "-i") == 0)
  do_include();
@end example

@c ----------------------------------------------------------------------
@node strlen, string
@heading @code{strlen}
@subheading Syntax

@example
#include <string.h>

size_t strlen(const char *string);
@end example

@subheading Description

This function returns the number of characters in @var{string}.

@subheading Return Value

The length of the string.

@subheading Example

@example
if (strlen(fname) > PATH_MAX)
  invalid_file(fname);
@end example

@c ----------------------------------------------------------------------
@node strlwr, string
@heading @code{strlwr}
@subheading Syntax

@example
#include <string.h>

char *strlwr(char *string);
@end example

@subheading Description

This function replaces all upper case letters in @var{string} with lower
case letters. 

@subheading Return Value

The string.

@subheading Example

@example
char buf[100] = "Hello";
strlwr(buf);
@end example

@c ----------------------------------------------------------------------
@node strncasecmp, string
@heading @code{strncasecmp}
@subheading Syntax

@example
#include <string.h>

int strncasecmp(const char *s1, const char *s2, size_t max);
@end example

@subheading Description

This function compares @var{s1} and @var{s2}, ignoring case, up to a
maximum of @var{max} characters. 

@subheading Return Value

Zero if the strings are equal, a positive number if @var{s1} comes after
@var{s2} in the ASCII collating sequense, else a negative number. 

@subheading Example

@example
if (strncasecmp(foo, "-i", 2) == 0)
  do_include();
@end example

@c ----------------------------------------------------------------------
@node strncat, string
@heading @code{strncat}
@subheading Syntax

@example
#include <string.h>

char *strncat(char *s1, const char *s2, size_t max);
@end example

@subheading Description

This function concatenates up to @var{max} characters of @var{s2} to the
end of @var{s1}.

@subheading Return Value

@var{s1}

@subheading Example

@example
strncat(fname, extension, 4);
@end example

@c ----------------------------------------------------------------------
@node strncmp, string
@heading @code{strncmp}
@subheading Syntax

@example
#include <string.h>

int strncmp(const char *s1, const char *s2, size_t max);
@end example

@subheading Description

This function compares upto @var{max} characters of @var{s1} and @var{s2}.

@subheading Return Value

Zero if the strings are equal, a positive number if @var{s1} comes after
@var{s2} in the ASCII collating sequense, else a negative number. 

@subheading Example

@example
if (strncmp(arg, "-i", 2) == 0)
  do_include();
@end example

@c ----------------------------------------------------------------------
@node strncpy, string
@heading @code{strncpy}
@subheading Syntax

@example
#include <string.h>

char *strcpy(char *s1, const char *s2, size_t max);
@end example

@subheading Description

This function copies up to @var{max} characters of @var{s2} into @var{s1}.

@subheading Return Value

@var{s1}

@subheading Example

@example
char buf[100];
strcpy(buf, arg, 99);
@end example

@c ----------------------------------------------------------------------
@node strnicmp, string
@heading @code{strnicmp}
@subheading Syntax

@example
#include <string.h>

int strnicmp(const char *s1, const char *s2, size_t max);
@end example

@subheading Description

This function compares @var{s1} and @var{s2}, ignoring case, up to a
maximum of @var{max} characters. 

@subheading Return Value

Zero if the strings are equal, a positive number if @var{s1} comes after
@var{s2} in the ASCII collating sequense, else a negative number. 

@subheading Example

@example
if (strnicmp(foo, "-i", 2) == 0)
  do_include();
@end example

@c ----------------------------------------------------------------------
@node strpbrk, string
@heading @code{strpbrk}
@subheading Syntax

@example
#include <string.h>

char *strpbrk(const char *s1, const char *set);
@end example

@subheading Description

This function finds the first character in @var{s1} that matches any
character in @var{set}.

@subheading Return Value

A pointer to the first match, or @code{NULL} if none are found.

@subheading Example

@example
if (strpbrk(command, "<>|"))
  do_redirection();
@end example

@c ----------------------------------------------------------------------
@node strrchr, string
@heading @code{strrchr}
@subheading Syntax

@example
#include <string.h>

char *strrchr(const char *s1, int c);
@end example

@subheading Description

This function finds the last occurrence of @code{c} in @code{s1}.

@subheading Return Value

A pointer to the last match, or @code{NULL} if the character isn't in
the string. 

@subheading Example

@example
char *last_slash = strrchr(filename, '/');
@end example

@c ----------------------------------------------------------------------
@node strsep, string
@heading @code{strsep}
@subheading Syntax

@example
#include <string.h>

char *strsep(char **stringp, char *delim);
@end example

@subheading Description

This function retrieves the next token from the given string, where
@var{stringp} points to a variable holding, initially, the start of the
string.  Tokens are delimited by a character from @var{delim}.  Each
time the function is called, it returns a pointer to the next token, and
sets *@var{stringp} to the next spot to check, or @code{NULL}. 

@subheading Return Value

The next token, or NULL.

@subheading Example

@example
main()
@{
  char *buf = "Hello  there,stranger";
  char **bp = &buf;
  char *tok;
  while (tok = strsep(bp, " ,"))
    printf("tok = `%s'\n", tok);
@}

tok = `Hello'
tok = `'
tok = `there'
tok = `stranger'
@end example

@c ----------------------------------------------------------------------
@node strspn, string
@heading @code{strspn}
@subheading Syntax

@example
#include <string.h>

size_t strspn(const char *s1, const char *set);
@end example

@subheading Description

This function finds the first character in @var{s1} that does not match
any character in @var{set}.  Note that the @code{NULL} bytes at the end
of @var{s1} counts, so you'll at least get a pointer to the end of the
string if nothing else. 

@subheading Return Value

The index of the found character.

@subheading Example

@example
int i = strcspn(entry, " \t\b");
if (entry[i])
  do_something();
@end example

@c ----------------------------------------------------------------------
@node strstr, string
@heading @code{strstr}
@subheading Syntax

@example
#include <string.h>

char *strstr(const char *s1, const char *s2);
@end example

@subheading Description

This function finds the first occurrence of @var{s2} in @var{s1}. 

@subheading Return Value

A pointer within @var{s1}, or @code{NULL} if @var{s2} wasn't found.

@subheading Example

@example
if (strstr(command, ".exe"))
  do_exe();
@end example

@c ----------------------------------------------------------------------
@node strtod, string
@heading @code{strtod}
@subheading Syntax

@example
#include <stdlib.h>

double strtod(const char *s, char **endp);
@end example

@subheading Description

This function converts as many characters of @var{s} that look like a
floating point number into one, and sets @var{*endp} to point to the
first unused character. 

@subheading Return Value

The value the string represented. 

@subheading Example

@example
char *buf = "123ret";
char *bp;
double x = strtod(buf, &bp);
@end example

@c ----------------------------------------------------------------------
@node _strtold, string
@heading @code{_strtold}
@subheading Syntax

@example
#include <stdlib.h>

long double _strtold(const char *s, char **endp);
@end example

@subheading Description

This function converts as many characters of @var{s} that look like a
floating point number into one, and sets @var{*endp} to point to the
first unused character. 

@subheading Return Value

The value the string represented. 

@subheading Example

@example
char *buf = "123ret";
char *bp;
long double x = _strtold(buf, &bp);
@end example

@c ----------------------------------------------------------------------
@node strtok, string
@heading @code{strtok}
@subheading Syntax

@example
#include <string.h>

char *strtok(char *s1, const char *s2);
@end example

@subheading Description

This function retrieves tokens from @var{s1} which are delimited by
characters from @var{s2}.

To initiate the search, pass the string to be searched as @var{s1}.  For
the remaining tokens, pass @code{NULL} instead. 

@subheading Return Value

A pointer to the token, or @code{NULL} if no more are found.

@subheading Example

@example
main()
@{
  char *buf = "Hello there, stranger";
  char *tok;
  for (tok = strtok(buf, " ,");
       tok;
       tok=strtok(0, " ,"))
    printf("tok = `%s'\n", tok);
@}

tok = `Hello'
tok = `there'
tok = `stranger'
@end example

@c ----------------------------------------------------------------------
@node strtol, string
@heading @code{strtol}
@subheading Syntax

@example
#include <stdlib.h>

long strtol(const char *s, char **endp, int base);
@end example

@subheading Description

This function converts as much of @var{s} as looks like an appropriate
number into the value of that number, and sets @var{*endp} to point to
the first unused character. 

The @var{base} argument indicates what base the digits (or letters)
should be treated as.  If @var{base} is zero, the base is determined by
looking for @code{0x}, @code{0X}, or @code{0} as the first part of the
string, and sets the base used to 16, 16, or 8 if it finds one.  The
default base is 10 if none of those prefixes are found.

@subheading Return Value

The value.

@subheading Example

@example
printf("Enter a number: "); fflush(stdout);
gets(buf);
char *bp;
printf("The value is %d\n", strtol(buf, &bp, 0));
@end example

@c ----------------------------------------------------------------------
@node strtoul, string
@heading @code{strtoul}
@subheading Syntax

@example
#include <stdlib.h>

unsigned long strtoul(const char *s, char **endp, int base);
@end example

@subheading Description

This is just like @code{strtol} (@pxref{strtol}) except that the result
is unsigned. 

@subheading Return Value

The value.

@subheading Example

@example
printf("Enter a number: "); fflush(stdout);
gets(buf);
char *bp;
printf("The value is %u\n", strtoul(buf, &bp, 0));
@end example

@c ----------------------------------------------------------------------
@node strupr, string
@heading @code{strupr}
@subheading Syntax

@example
#include <string.h>

char *strupr(char *string);
@end example

@subheading Description

This function converts all lower case characters in @var{string} to
upper case. 

@subheading Return Value

@var{string}

@subheading Example

@example
char buf[] = "Foo!";
strupr(buf);
@end example

@c ----------------------------------------------------------------------
@node strxfrm, locale
@heading @code{strxfrm}
@subheading Syntax

@example
#include <string.h>

size_t strxfrm(char *s1, const char *s2, size_t max);
@end example

@subheading Description

This copies characters from @var{s2} to @var{s1}, which must be able to
hold @var{max} characters.  Each character is transformed according to
the locale such that @code{strcmp(s1b, s2b)} is just like
@code{strcoll(s1, s2)} where @code{s1b} and @code{s2b} are the
transforms of @code{s1} and @code{s2}. 

@subheading Return Value

The actual number of bytes required to transform @var{s2}, including the
@code{NULL}. 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -