Hi, I'm working on my second C program ever and I'm lost...
I have 2 source files. I'm passing a char ** from one function in one file to another function in a second file, it's losing the reference and pointing to garbage. Can some one tell me what I'm doing wrong ?
Here's some code
Code:
FILE1.C
int _tmain(int argc, _TCHAR* argv[])
{
char ** input_word_list;
/* THIS WORKS WELL */
input_word_list = get_input_line();
/* THIS WORKS FINE */
int i=0;
while ( (strcmp(input_word_list[i], EOW)) ){
printf("----> %s\n",input_word_list[i++]);
}
get_db_con(input_word_list);
return 0;
}
FILE2.c
int get_db_con(char ** input_word_list)
{
/* THIS FAILS WHY ???? */
int i=0;
while ( (strcmp(input_word_list[i], EOW)) ){
printf("FROM get_db_con ----> %s\n",input_word_list[i++]);
}
return 0;
}
and here is the included header for each FILE1/2
#define EOW "~"
int get_db_con(char **);
char ** get_input_line(void);
***********************************************
I used malloc in the first file in a local function, do I need to do somthing FAR etc.. ?? How do I ?
Is that why it's losing the data, cause it's out of scope, how do I scope it right ?
Thanks for the help,
-Areal