I want to remove the last new line from the following function:
void WriteToFile(node *tree)
{
void Write(node*);
fp = fopen("dictionary.txt","w");
if(fp==NULL)
{
printf("Cannot open file for writing data...");
}
else //if(tree==NULL)
{
if(tree!=NULL)
{
Write(tree);
}
fclose(fp);
}
}
void Write(node *tree)
{
if(tree!=NULL)
{
fprintf(fp,"%s:%s\n",tree->word,tree->meaning);
Write(tree->left);
Write(tree->right);
}
}
I am using this function to write to a text file the contents of a BST, and I dont want it to write the last new line, how can I remove it?