Undefined pointer issue
I can't figure out why I get a runtime error when I run my function. The function fails without running a single line of my function. The error reads: Run-Time Check Failure #3 - The variable 'parsed' is being used without being defined.
In my main my code sets up like this:
char* str9 = "This is a test";
char* delim = "i";
char** parsed;
int leng;
split(str9, delim, parsed, &leng);
the prototype for split is: int split(char* tosplit, char* delim, char** parsed, int* len)
I would put up split, but like I said the error happens before a single line of the function is called. It occurs right at the call for some reason.
Does anyone have any ideas why this is happening?
[746 byte] By [
Iteria] at [2007-11-20 11:04:52]

# 1 Re: Undefined pointer issue
You haven't initialized it/assigned anything to it.
All of your other pointers are initialized. Why not parsed?
# 2 Re: Undefined pointer issue
I'll assume that parsed is uninitialized because the type of the parameter being char ** indicates the expectation that it will be allocated by the function, but I would expect to see it declared as a type char *, and it's ADDRESS should be supplied to split.
Other than that, I think that if the error occurs in the assembler view of the debug BEFORE the call is really issued, then something ELSE has setup a condition by which the error occurs.
JVene at 2007-11-9 1:26:00 >

# 3 Re: Undefined pointer issue
The strings pointed to by str9 and delim are literals - which are constants. They must not be modified. They should be declared as const char* instead of char*. This correction will also cause a change in the split() function interface. Since, you are getting a runtime error. I would assume 2 probabilities:
1) You are modifying those literals
2) You are appending/assigning to "parsed" without proper memory allocation.
Try putting a breakpoint in the function split() and see where it fails. You should be capable of debugging your programs.
# 4 Re: Undefined pointer issue
The way you are calling split doesn't look right (even without seeing the implementation. Should probably be char* str9 = "This is a test";
char* delim = "i";
char* parsed;
int leng;
split(str9, delim, &parsed, &leng);