满意答案
#include
#include #define N 80void bky();
int fun(char *ptr) {
/**********Begin**********/
char *p = ptr,*q,ch;
int counter = 0;
while(*p) {
ch = *p;
if(((ch < 'A') || (ch > 'Z')) && ((ch < 'a') || (ch > 'z'))) {
q = p;
while(*q) {
*q = *(q + 1);
q++;
}
p--;
}
p++;
}
return (int)(p - ptr);
/********** End **********/
}int main() {
char str[N];
int s;
printf("input a string:");gets(str);
printf("The origINal string is :"); puts(str);
s=fun(str);
printf("The new string is :");puts(str);
printf("There are %d char IN the new string.\n\n",s);
bky();
return 0;
}void bky() {
FILE *IN,*OUT;
char sin[N];
int iOUT;
IN = fopen("F:\\VC\\in.dat","r");
if(IN == NULL) {
printf("Please Verify The Currernt Dir..it May Be Changed");
}
OUT = fopen("F:\\VC\\out.dat","w");
if(OUT == NULL) {
printf("Please Verify The Current Dir.. it May Be Changed");
}
fscanf(IN,"%s",sin);
iOUT = fun(sin);
fprintf(OUT,"%d %s\n",iOUT,sin);
fclose(IN);
fclose(OUT);
}
10分享举报