0

code:

typedef struct
{
 int weight;
 char c;
 int parent, lchild, rchild;
} Node, *HTree;
void findmin(HTree ht, int len, int *p1, int *p2)
void CreateHTree(HTree ht, int n)
void print(HTree ht,int n)
{
 for(int i=1;i<=2*n-1;i++)
 {
 printf("%d %d %d\n",ht[i].parent,ht[i].lchild,ht[i].rchild);
 }
}
int main()
{
 int n;
 scanf("%d", &n);
 HTree ht;
 char **hc;
 CreateHTree(ht, n);
 print(ht,n);
 return 0;
}

Well, when I transfer parameter ht, it seems never transfer correctly. Can someone tell me how to solve it? :(

I just want to know what's wrong.

asked May 10, 2024 at 6:40
2
  • You have no semicolons after the prototypes for findmin and CreateHTree, so this can't even compile. If you're going to provide example code in a question, always provide complete code (which this isn't) that compiles. Otherwise, no one can help you. See stackoverflow.com/help/minimal-reproducible-example Commented May 10, 2024 at 15:30
  • ht is an uninitialized pointer, and CreateHTree() returns nothing. So there is no way to get anything back from CreateHTree(). What the heck is hc? It is not used. Commented May 10, 2024 at 15:34

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.