so im im just writing up the code now but ive come up against a anoher same problem
Code:
struct treeNode {
struct treeNode *yesPtr; /* pointer to yes subtree */
int num; /* node value */
char question[50];
struct treeNode *noPtr; /* pointer to no subtree */
}; /* end structure treeNode */
typedef struct treeNode TreeNode; /* synonym for struct treeNode */
typedef TreeNode *TreeNodePtr; /* synonym for TreeNode* */
void insertNode(TreeNodePtr *treePtr, char text[], int value);
void NewGame ();
void Continue ();
void inOrder( TreeNodePtr treePtr );
int main (void)
{
int choice;
do
{
printf("Please enter your choice: ");
scanf("%i",&choice);
}
while ((choice <= 0) && (choice >=4));
if (choice == 1)
{
NewGame();
}
else if (choice == 2)
{
Continue();
}
else if (choice == 3)
{
return 0;
}
scanf ("%i",&choice);
return 0;
}
void NewGame ()
{
char Filename[50];
FILE *in;
TreeNodePtr rootPtr = NULL; /* tree initially empty */
int Qnum;
char Qtext[50] = "Are You Female";
printf ("This is the new game function\n\n");
printf ("Please provide the new file name: ");
scanf ("%s",Filename);
printf ("\n\n%s",Filename);
in = fopen(Filename,"rwb");
if ( in == NULL )
{
perror ( "Unable to open the file" );
exit ( EXIT_FAILURE );
}
else
{
Qnum = 1;
insertNode(&rootPtr, Qtext[50], Qnum);
}
}
void insertNode( TreeNodePtr *treePtr, char text[], int value )
{
/* if tree is empty */
if ( *treePtr == NULL ) {
*treePtr = malloc( sizeof( TreeNode ) );
/* if memory was allocated then assign data */
if ( *treePtr != NULL ) {
( *treePtr )->num = value;
( *treePtr )->question[50] = text[50];
( *treePtr )->yesPtr = NULL;
( *treePtr )->noPtr = NULL;
} /* end if */
else {
printf( "%i not inserted. No memory available.\n", value );
} /* end else */
} /* end if */
else { /* tree is not empty */
/* data to insert is less than data in current node */
if ( value < ( *treePtr )->num ) {
insertNode( &( ( *treePtr )->yesPtr ), text[50], value );
} /* end if */
/* data to insert is greater than data in current node */
else if ( value > ( *treePtr )->num ) {
insertNode( &( ( *treePtr )->noPtr ), text[50], value );
} /* end else if */
else { /* duplicate data value ignored */
printf( "dup" );
} /* end else */
} /* end else */
}
void Continue()
{
printf ("This is the continue game function");
}
im getting errors when i call the insertnode function its to do with the parameters and the string useage im using
can anyone help me
ps i have left some bits out but they are working so ive not included them ....... for now