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 - strcountptr() count character occurrences in pointed-to string http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 strcountptr()       Count character occurrences in pointed-to string
------------------------------------------------------------------------------
 Declaration
   string.hdr

 Syntax
   func uint strcountptr extern
   param value ulong pString, ;
         value byte  bChar

 Arguments
   pString is a pointer to a string to scan.

   bChar is the character to search for.

 Return
   The number of occurrences of bChar in pString.

 Description
   The strcountptr() function scans a string (supplied as a memory pointer)
   for a passed character, and returns the number of its occurrences.

 Example
   #define EXAMPLE_STRING
   #include example.hdr

   proc Test_strcountptr
   vardef
      ptr( char ) pMem
   enddef
   pMem := malloc( 100 )                  // allocate memory
   *pMem := "Hello world"                 // copy string
   ? strcountptr( pMem, asc( "l" ) )      // print 3
   ? strcountptr( pMem, asc( "o" ) )      // print 2
   free( pMem )                           // free buffer
   endproc

   proc main
   Test_strcountptr()
   endproc

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