Why does this work:
//split returns (char**)
char *temp2;
temp2=split(array[i],'=')[1];
and this doesn’t:
char **temps;
temps[0]=temp2; //crashes
or this:
temps[0]=split(array[i],'=')[1]; //crashes
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.
tempsis just a pointer to achar*, but it has no initalized, sensible value!temps[0]is equivalent to*(temps + 0), but you cannot dereference a garbage value — you first have to maketempspoints somewhere useful, e.g. by allocating memory for it.If you want to store some
char*s with automatic storage, then declare an array of char pointers instead: