Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Code me the php explode function into c or c++

  1. Nov 29, 2004 #1
    can someone code me the php explode function into c or c++ that would work with original strings?
    thanks in advance
     
  2. jcsd
  3. Nov 30, 2004 #2

    dduardo

    User Avatar
    Staff Emeritus

    Um, there isn't anything to do if you use the C-style strings since it is already in array format. For example:

    char *str = "hello";

    printf("%c",str[0]) /*Would print out an h*/
    printf("%c",str[1]) /*Would print out an e*/

    Same thing applies to the C++ STL strings. The class actually overloads the [] operator so you can access the string just like an array.
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook




Loading...
Similar Threads for Code explode function Date
Safe removal of an external disk Jan 30, 2018
Positive-only sigmoid function Oct 20, 2017
Cautionary Tale of "Unpublished" 17 Lines of Code Mar 25, 2016
Printing a QR code on a POS receipt Sep 26, 2013
Parallelizing my C++ code Mar 27, 2013