howdy boys and girls:
ok i'm reading in a file for a binary tree where the left subtree of a node is in parentheses following the node key and the right subtree follows by a comma:
ie: 1(2,3(10),4(5(8),6(9),7)
would result in 1 at root 2 at left and 4 at right .. this is just the first branch..
my function pulls in this file using ifstream scanned into a char array, i'd use integer but got loads of errors...
my problem i learned was handling two and then will be 3 digit numbers... i guess i should cat them together but how? or, how would i go about using an int array? then if so how should i attack my problem of sorting to various branches?Code:char str[82]; ifstream b_file("./BinaryTree.dat"); b_file>>str; cout<<str<<endl; for(int i=0;i<strlen(str);i++) { if(str[i] == '(') {i++; cout<<"Insert Left Subtree"<<endl;} else if(str[i] == ',') {i++; cout<<"Insert Right Subtree"<<endl;} else if(str[i] == ' ') {i++; cout<<"Ignoring Blank Space"<<endl;} else{cout<<strcat(str[i--],str[++i])<<endl;} cout<<str[i]<<endl; } b_file.close();
thanks for your time



LinkBack URL
About LinkBacks


