試してないけどこれじゃあかんかな
char* p = strchr(buf, '/');
if (p) {
subnetmask = atoi(p+1);
*p = '\0';
strcpy(addr_tmp, buf);
}