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

AI Thread Summary
The discussion centers on the request for a C or C++ implementation of PHP's explode function, which splits a string into an array based on a delimiter. It is noted that C-style strings are inherently in array format, allowing direct access to individual characters using array indexing. For example, accessing characters in a string can be done with syntax like `str[0]` for 'h' and `str[1]` for 'e'. Similarly, C++ STL strings also support array-like access through operator overloading, making it unnecessary to replicate the explode function for basic string manipulation tasks.
rsnd
Messages
26
Reaction score
0
can someone code me the php explode function into c or c++ that would work with original strings?
thanks in advance
 
Technology news on Phys.org
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.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...

Similar threads

Replies
22
Views
3K
Replies
6
Views
2K
Replies
13
Views
2K
Replies
3
Views
5K
Replies
21
Views
6K
Replies
1
Views
5K
Back
Top