删除字符串中的字符
#include<stdio.h>char s[]="this,is,string";
main()
{
char c=",";printf("%s/n",s);
sdele( );printf("%/n",s);
}
sdele(char s[],char c)
{
int i,j;
for(i=j=0;s[i]!='/0';++i)
if(s[i]!=c s[j++]= ( );
( );
}
#include <stdio.h> void sdele( char s[], char c ); int main( void ) { char s[] = "this,is,string"; const char c = ','; printf( "%s\n", s ); sdele( s, c ); printf( "%s\n", s ); return 0; } void sdele( char s[], char c ) { size_t j = 0; for( size_t i=0; s[i]!='\0'; ++i ) if( s[i] != c ) s[j++] = s[i]; s[j] = '\0'; }