Ok my assignment is to teach us how to put bits of programs together.
One program is supposed to have just the main.
Another program has all of the functions that main calls.
Then there is a header that holds the function headers.
So far my main is just this...
Code:
#include <stdio.h>#include <stdlib.h>
#include <string.h>
#include "bin-library.c"
#include "bin-library.h"
int main(void)
{
struct node *root = NULL;
int *array_of_numbers;
int Max_lines = 0;
int i;
array_of_numbers = numbers(&Max_lines);
array_of_numbers = sort_array(array_of_numbers, Max_lines);
getchar();
return 0;
}
My functions are in this program....(I'm going to edit out the functions that are working and just show you the one I'm having problems with to save space.
Code:
#include "bin-library.h"
struct node *addNode( int x ){
struct node *new_node;
new_node = malloc( sizeof(struct node) );
new_node->value = x;
new_node->left = NULL;
new_node->right = NULL;
return new_node;
}
And the header is here (again editing out the functions that work)
Code:
#include "bin-library.c"
struct node {
int value;
struct node *left;
struct node *right;
};
struct node *addNode( int x );
So I think I have the #include the stuff set up right. ( I don't even think I need the last #include "bin-library.c"
But when I run my code (notice I'm not calling the function yet, it's just declared...
My function is giving me several warnings.
1.) invalid application of 'sizeof' to incomplete type 'node'
2.) dereferencing pointer to incomplete type ( this one is given three times, for the new_node->value, new_node->left, and new_node->right.
It's like it's not seeing the header. Any ideas what I'm doing wrong?