随笔 - 13, 文章 - 18, 评论 - 18, 引用 - 0
数据加载中……

删除特定字符串

从字符串中删除指定的字符串,
 
如"Battle of the Vowels: Hawaii VS Grozny"
删除 "aeiou"
 
则 最终为 "Bttl f th Vwls: Hw Vs Grzny"
 
void RemoveChars(char str[], char remove[])
{
   int src, dst, removeArray[256];
   for(src=0; src<256, src++)
      removeArray[src] = 0;
   
    src =0;
    while(remove[src])
     {
        removeArray[remove[src]]=1;
        src++;
     }
 
    src=dst=0;
  
    do
    {
      if(!removeArray[str[src]])
           str[dst++]=str[src];
    }while(str[src++]);
 
}

posted on 2007-02-03 10:16 JackLi 阅读(390) 评论(0)  编辑 收藏 引用 所属分类: Examination


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理