At least your “resp” is not properly / fully created, I think. See the last three links in: Intializing Double Array TH2