Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <ctype.h>
- #define MAX_STR_LEN 64
- int main(){
- char ch, string[MAX_STR_LEN], newstr[MAX_STR_LEN];
- int n=0, i, j=0;
- while((ch=getchar())!='$')
- string[n++]=ch;
- string[n]='\0';
- for(i=0;i<n;i++){
- if(isalnum(string[i]))
- newstr[j++]=string[i];
- else if(((isspace(string[i]))&&(isalnum(string[i+1])))&&(j!=0))
- newstr[j++]=' ';
- }
- newstr[j]='\0';
- printf("The resulting string is:\n%s\n", newstr);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement