char * defangIPaddr(char * address){ int len = strlen(address); char* s = (char*)calloc(sizeof(char), len*2); char* buffer; buffer = strtok(address, "."); while (buffer){ strcat(s, buffer); buffer = strtok(NULL, "."); if (buffer == NULL) break; strcat(s, "[.]"); } return s; }
原文:https://www.cnblogs.com/ganxiang/p/14022506.html