1. PF Insights is off to a great start! Fresh and interesting articles on all things science and math. Here: PF Insights

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

  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. dduardo

    dduardo 1,919
    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.
     
Know someone interested in this topic? Share a link to this question via email, Google+, Twitter, or Facebook

Have something to add?
Similar discussions for: Code me the php explode function into c or c++
Loading...