[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
  STRCHR

  .  Summary

  strchr(str <s>, int <pos>, int <c);

  .  Description

  The strchr function is used to search for a character within a
  string. <s> is the string to search, and <pos> is the starting posi-
  tion of the search, and <c> is the character (ASCII value) to search
  for. If the character, its offset is returned, otherwise a value of
  -1 is returned. Note that the first character in a string has an
  offset of 0, not 1 as in some languages.

  .  Return Value

  An integer value as described above.

  .  Example

  // Count how many times a certain char occurs in a string

  int i, count = 0;
  str s[] = "abcabcabcabcabc";

  i = 0;
  do
   {
    i = strchr(s, i, 'a');
    if (i != -1)
     count = count + 1;
   }
  while (i != -1);

See Also: ASCII table
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson