Wouldn't doing new weaponid = strval(inputtext); just work fine? I've been doing this directly and have no issues. Though, sscanf could be a better choice.
strval will return 0 if the text doesn't contain only numbers. Checking if the index 0 and 1 are equal to '0' and '\0' respectively is not something people would do and sscanf is really much easier to use.