码迷,mamicode.com
首页 > 其他好文 > 详细

ctci1.4

时间:2014-10-09 14:43:28      阅读:243      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   ar   for   sp   div   log   ad   

char* newstr(char * str){
    if(str == NULL)
        return NULL;
    int blank = 0;
    int len = strlen(str);
    int i = 0;
    for(i = 0; i < len ; i++)
        if(str[i] ==  )
            blank++;
    int j = 0;
    char * newhead = new char[len + blank*2 +1];
    for(i = 0; i < len; i++){
        if(str[i] !=  )
            newhead[j++] = str[i];
        else{
            newhead[j++] = %;
            newhead[j++] = 2;
            newhead[j++] = 0;
        }
    }
    newhead[j] = \0;
    str = newhead; 
    return str;
}

ctci1.4

标签:style   blog   color   ar   for   sp   div   log   ad   

原文地址:http://www.cnblogs.com/jilichuan/p/4013211.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!