码迷,mamicode.com
首页 > 编程语言 > 详细

从字符数组中删除特定字符

时间:2015-07-09 19:50:28      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:字符数组   删除特定字符   

#include<stdio.h>
int main()
{
	char str[100],c;
	int j,k;
	printf("please input a string:");
	gets(str);
	printf("\nEnter a character:");
	c=getchar();
	for(j=k=0;str[j]!='\0';j++)
		if(str[j]!=c)
			str[k++]=str[j];
		str[k]='\0';
	printf("\n%s",str);
}
<pre name="code" class="cpp">please input a string:wqeqwe

Enter a character:w

qeqePress any key to continue




版权声明:本文为博主原创文章,未经博主允许不得转载。

从字符数组中删除特定字符

标签:字符数组   删除特定字符   

原文地址:http://blog.csdn.net/u012701023/article/details/46820887

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