當前位置:編程學習大全網 - 電腦編程 - 編制函數fun,其功能是:刪除壹個字符串中指定的字符。

編制函數fun,其功能是:刪除壹個字符串中指定的字符。

#include <stdio.h>

void fun(char str[],char ch)

{ int i,j;

for(i=0;str[i]!='\0';i++)

if(str[i]==ch)

{

for(j=i;str[j]!='\0';j++)

str[j]=str[j+1];

}

}

int main()

{ char str[100],ch;

printf("enter a string :"); // 不需要提示語的話刪去此行

gets(str);

printf("enter you want delete letter : ");// 不需要提示語的話刪去此行

ch=getchar();

fun(str,ch);

printf("%s\n",str);

return 0;

}

  • 上一篇:福州偉仕駿業機電設備有限公司怎麽樣?
  • 下一篇:加工中心的尋邊器怎麽用的,哪位大蝦知道告訴下謝謝
  • copyright 2024編程學習大全網