There are a number of problems here. Here are a few:
1)where's tempbranch defined? it should be a local variable.
2)You call malloc, but never free. Then you destroy the pointer holding the...