#include #include #include #include #include #define MAX 100 void bubblesort(char *sp[], int n); void swap(char *to[], char *from[]); int main(void) { clrscr(); FILE *fptr_in, *fptr_out; char ch[MAX]; char *ptr, *chr[MAX]={NULL}; register int i; int spaces=0; int j, same[MAX]; for(i=0; i> "); fflush(stdin); gets(ch); fptr_in = fopen("C:\INPUTS.TXT", "w"); fprintf(fptr_in, "%s", ch); fclose (fptr_in); for(i=0; ch[i] != NULL; i++) { if (ch[i]==' ') spaces++; } for(i=0; ch[i] != NULL; i++) { ch[i]=toupper(ch[i]); if (ch[i] == '.' || ch[i] == ',' || ch[i] == '?' || ch[i] == '!' || ch[i] == '"' || ch[i] == ';') ch[i] = ' '; } printf("\n\nThere are %d words in this message.\n", spaces+1); fptr_out = fopen("C:\OUTPUTS.TXT", "w"); ptr = strtok(ch, " "); if (ptr) chr[0] = ptr; for(i=0; i1) { fprintf(fptr_out, "%s: %d times\n", chr[i], same[i]); i=i+same[i]-1; } else { fprintf(fptr_out, "%s: %d time\n", chr[i], same[i]); } } fclose(fptr_out); fflush(stdin); printf("\n\nHit any key to EXIT"); getch(); return 0; } void bubblesort(char *v[], int n) { int i; for(n=n-1; n >=0; n -=1) { for(i=0; i 0) swap(v+i, v+i+1); } } } void swap(char *to[], char *from[]) { char *temp; temp = *from; *from = *to; *to = temp; }