c:踢掉字符串中的指定字符
#include<stdio.h> #include<stdlib.h> int main(void){ char s[] = "hello"; char d = 'l'; int i,j; for(i=j=0;s[i]!='\0';i++){ if(s[i]!=d){ s[j++] = s[i]; } } s[j] = '\0'; printf("the power number is: %s",s); system("pause"); }
#include<stdio.h> #include<stdlib.h> int main(void){ char s[] = "hello"; char d = 'l'; int i,j; for(i=j=0;s[i]!='\0';i++){ if(s[i]!=d){ s[j++] = s[i]; } } s[j] = '\0'; printf("the power number is: %s",s); system("pause"); }