Code:char s[] = "amajjjfgy, torsrfew"; for (i=0; i++; s[i]){ if(isalpha(s[i]){ strcpy(&s[i], &s[i+1]); } }
Good example of in-place string manipulation, and standard library use. But, may I suggest using two index variables, to reduce redundant copies, and migrating to strncpy or strlcpy. Of course strcpy is completely safe in your example, but it sets a good example to copy&pasters. Oh, and do you mean: if( ! isalpha(s )