Please check return value, since strchr() may dereference this pointer
Also, since you are using c++, you may use its options like streams to parse list of hosts