The problem is your strtod function return 0 and so all the values are being lost. Use atoi instead of that as that can help you towards success.