面试题---删除串中指定的字符
2017-10-28 17:59
274 查看
#include <iostream> #include <fstream> #include <string> #include <cstring> #include <vector> using namespace std; void del(char *str,char c) { char *head = NULL; char *p = NULL; head = p = str; while(*p != '\0') { if(*p != c) { *str = *p; str++; } p++; } *str = '\0'; } int main() { cout<<"输入一个字符串:"<<endl; char value[256]; cin>>value; cout<<"输入要删除的字符"<<endl; char c; cin>>c; del(value,c); cout<<"删除后的结果为:"<<value<<endl; return 0; }
相关文章推荐
- 【我解C语言面试题系列】010 从相应位置开始删除指定字符串的相应个字符
- 【我解C语言面试题系列】010 从相应位置开始删除指定字符串的相应个字符
- 【我解C语言面试题系列】011 删除指定字符串的相应字符
- 【我解C语言面试题系列】011 删除指定字符串的相应字符
- Exe7 删除字符串中指定的字符 (还有有问题——指针的问题)
- 问题 F: C语言实验——删除指定字符
- 删除字符串中所有指定的字符
- [转载]c删除字符串中指定字符
- 删除字符串中的指定字符
- 字符串中删除指定字符
- 百度面试题:删除所有ascii编码的字符和数字
- 删除字符串中的指定字符
- Java中如何从一个字符串中删除指定字符
- ytu 1998:C语言实验——删除指定字符
- JAVA 删除字符串里指定字符
- 【链表面试题】删除无头单链表的非尾节点,插入一个元素到无头链表指定位置
- 删除字符串中指定的一些字符
- 删除串中指定的字符
- 统计英文文章中空格数,单词数,字符数,并删除指定字符 (c语言)
- 在字符串中删除特定的字符(程序员面试题精选100题)