I think this is not a correct answer.
Have you tried to use -z instead of -i ?
Why for -i or -n error is not raised ?
I am not sure, if the answer is not correct. The strings like "-a" ... "-z" ,exept -"i" and "-n", are converted to -0. "-i" and "-n" are converted to 0. Why not -0, I don't know (perhaps my first answer).
Your way to check for an error is not so good. The pointer p gives you the position how far the string was read. If there a "a", "b" or something else strtod() knows that there is not a number. In the case of 'i' or 'n' there could come a string like "inf", "infinity" or "nan". Try strings like "inx", "nam" or something else and look at the pointer p. So in the case of "-i" and "-n" the hole strings is read and the string behind the pointer p is empty and you think the conversion of the string is correct.
If this behavior is correct, i don't know.