Testing embedded code to see if indentation is honoured
#include
#include
#include
#include "getword.h"
#define MAXWORD 128
typedef struct bintree
{
struct bintree *lower;
struct bintree *higher;
char *word;
int count;
} Node;
//typedef struct bintree Node;
Node* addNode( char* word, Node *tree );
void printTree( Node* tree );
int main(int argc, char *argv[])
{
char word[MAXWORD];
Node *first = NULL;
while (getword(word, MAXWORD) != EOF)
{
first = addNode( word, first );
}
printTree( first );
exit(0);
}
Node* addNode( char* word, Node *tree )
{
if ( tree == NULL )
{
tree = ( Node *) malloc ( sizeof tree );
tree->word = strdup( word );
tree->count = 1;
tree->higher = tree->lower = NULL;
return tree;
}
else
{
if ( strcmp(word, tree->word) == 0 )
{
tree->count++;
return tree;
}
}
if ( strcmp(word, tree->word) > 0 )
{
tree->higher = addNode( word, tree->higher );
}
else
{
tree->lower = addNode( word, tree->lower );
}
return tree;
}
Back to normal?
Comment : Success, but not straightforward. It appears that the forum editor honours embedded HTML tags indirectly via the edit button. Note font changes to non-proporttional
Edited By SillyOldDuffer on 04/11/2017 19:48:30
Edited By SillyOldDuffer on 04/11/2017 19:49:24
Edited By SillyOldDuffer on 04/11/2017 19:51:39
Edited By SillyOldDuffer on 04/11/2017 19:56:35