troubleshooting Question

manipulating double arrays sent to function

Avatar of highrate
highrate asked on
C
5 Comments2 Solutions236 ViewsLast Modified:
Check the code, should be self explanitory what I'm trying to do.

The function crashes on line:

thespliced[i_word_num][i_word] = string[i_string];

Obviously because I haven't allocated memory for it.

How do allocate memory for a double array?
in the parse function:

char **spliced;
return_val = splice(string,thespliced);

int splice(char *string, char *thespliced[])
{


        int i_string=0;
        int i_word_num=0;
        int i_word=0;
        int i=0;


        for( ; i_string < (strlen(string) - 1) ; ++i_string)
        {


                if(string[i_string] == ' ')
                {
                        ++i_word_num;
                        i_word = 0;
                        continue;
                }
                thespliced[i_word_num][i_word] = string[i_string];
                ++i_word;
        }

        return i_word;
}
ASKER CERTIFIED SOLUTION
mccarl
IT Business Systems Analyst / Software Developer
Join our community to see this answer!
Unlock 2 Answers and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros