Question on passing array arguments to function, and not printing
I'v been working on a binary tree problem. I know there are those that only take one variable, prob an int or a char. However, my instructions were to pass a struct with addresses, phone numbers etc. My program compiles but perhaps my logic is crap. I believe it lies in the way i pass the array arguments to the insert function.
My function takes it like this:
Code:
BST insertnode(BST t, int x,int a,char *array)
{
if(t==NULL) {
t=(node*)malloc(sizeof(node));
if(t==NULL) printf("\n Out of Space !!");
else {
t->info = x;
t->phone=a;
t->fname[90]=*array;
t->left = t->right = NULL;
}
}
else
if (x<t->info) {
t->left=insertnode(t->left,x,a,array);
}
else
if (x>t->info) {
t->right=insertnode(t->right,x,a,array);
}
return t;
}
Everything seems to work fine, but when i try to print my information, i get the info and phone to the screen, but the fname doest print anything, which i assume is a problem the way im passing it to the function. ANyway any comments, or help would be appreciated.