I have a char* like this “1 10 14 16”
I want to split it to integer array like 1,10,14,16…
how i do that?
I have a char* like this 1 10 14 16 I want to split
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I suggest using strtol in a loop, using explicitly its
endptrargument, something like:if you want to accumulate all the numbers in an array, replace
do_something_useful_with_the_number (l);with code growing that array (probably usingmallocand/orrealloc…)