Character as a node
It errors when i pointer the character to a node how to fix this?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
struct Node
{
char story[1000];
struct Node *left, *right;
};
struct node *newNode(char letter[1000])//this part errors
{
struct node *node = (struct node*)sizeof(struct node));
strcpy(node->story, letter);
strcpy(node->left, NULL);
strcpy(node->right, NULL);
return node;
}
|
Last edited on
I tried the code you sent and how to fix the error in the
1 2 3 4 5 6
|
void printPathsRecur(struct node* node, int path[], int pathLen)
{
if (node == NULL) return;
strcpy_s(path[pathLen] = node->data);
pathLen++;
|
part?
I used
1 2 3 4 5 6
|
struct node
{
char data[1000];
struct node* left;
struct node* right;
};
|
I fixed it and i run it. and it says strcpy_s does not take 2 arguments
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
void printPathsRecur(struct node* node, char path[], int pathLen)
{
if (node == NULL) return;
strcpy_s(&path[pathLen], node->data);
pathLen++;
if (node->left == NULL && node->right == NULL)
{
printArray(path, pathLen);
}
else
{
printPathsRecur(node->left, path, pathLen);
printPathsRecur(node->right, path, pathLen);
}
}
|
Thank you! I have another problem but i think it's off topic so i'll just add another topic :)
Topic archived. No new replies allowed.