Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - strcount() count the occurrences of a character in a string http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 strcount()          Count the occurrences of a character in a string
------------------------------------------------------------------------------
 Declaration
   string.hdr

 Syntax
   func uint strcount extern
   param const char cString, ;
         value byte bChar

 Arguments
   cString is a string to scan.

   bChar is the character to search for.

 Return
   The number of occurrences of bChar in cString.

 Description
   The strcount() function scans a string for a passed character, and
   returns the number of its occurrences.

 Example
   #define EXAMPLE_STRING
   #include example.hdr

   proc Test_strcount
   vardef
      char cString
   enddef
   cString := "Hello world"
   ? strcount( cString, asc( "h" ) )      // print 0
   ? strcount( cString, asc( "H" ) )      // print 1
   ? strcount( cString, asc( "l" ) )      // print 3
   endproc

   proc main
   Test_strcount()
   endproc

See Also: strcountptr()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson