I am trying to split a char array with delimiter.
This gives me a runtime error:
#include <iostream>
#include <cstring>
int main()
{
    char* largechars = "q=test&use=bingo";
    char* chars_array = strtok(largechars, "&");
    while(chars_array)
    {
        std::cout << chars_array << '\n';
        chars_array = strtok(NULL, "&");
    }
}
Demo here http://ideone.com/OpNssn
This program works fine:
#include <iostream>
#include <cstring>
int main()
{
    char largechars[] = "q=test&use=bingo";
    char* chars_array = strtok(largechars, "&");
    while(chars_array)
    {
        std::cout << chars_array << '\n';
        chars_array = strtok(NULL, "&");
    }
}
Demo here http://ideone.com/Ye8C8k
What is the issue here?
 
     
     
    