when writing those error messages, always include the actual dimension in the message, i.e.
"The length of node array (%d) and weight array (%d) should be the same\n"