How to split a string into tokens by '&'
in C?
相关问题
- Multiple sockets for clients to connect to
- What is the best way to do a search in a large fil
- glDrawElements only draws half a quad
- Index of single bit in long integer (in C) [duplic
- Equivalent of std::pair in C
I would do it something like this (using
strchr()
):strchr(const char *s, int c)
returns a pointer to the next location ofc
ins
, orNULL
ifc
isn't found ins
.You might be able to use
strtok()
, however, I don't likestrtok()
, because:"a&&b&c"
, the returned tokens are"a"
,"b"
, and"c"
. Note that there is no empty token after"a"
.You can use the strok() function as shown in the example below.
strtok / strtok_r