New problem, this one is kinda crazy. The program reads correctly up to the value G, then letters start getting mixed up.
Code:
#include "bst_inter.h"
void bst_letter_fill ( tree_t *T )
{
FILE *in1, *in2;
bst_item data;
in1 = fopen("english.txt", "r");
in2 = fopen("cipher.txt", "r");
while (fscanf(in1, "%c", &data.key) != EOF && fscanf(in2, "%c", &data.code) != EOF)
bst_insert(T, &data);
fclose (in1);
fclose (in2);
}
where data includes a code character and a key character.
english.txt: ABCDEFGHIJKLMNOPQRSTUVWXYZ
cipher.txt: TSWEPFARUZMBCIYLJXHQOKNGVD
The resulting tree is:
Code: A Key: T
Code: B Key: S
Code: C Key: W
Code: D Key: E
Code: E Key: P
Code: F Key: F
Code: X Key: G
Code: H Key: R
Code: I Key: U
Code: J Key: Z
Code: K Key: M
Code: W Key: N
Code: P Key: L
Code: O Key: Y
Code: T Key: Q
Code: R Key: X
Code: Y Key: V
Any ideas why it would not read (or print?) the whole text file, and why the letters only start getting rearranged after F? Any help is greatly appreciated!