Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- #include <string.h>
- void newstring(char *string);
- int main(void){
- char string1[20];
- puts("Keep entering strings (enter quit to quit obviously).");
- scanf("%s", string1);
- while(strcmp(string1, "quit")!=0){
- newstring(string1);
- scanf("%s", string1);
- }
- return 0 ;
- }
- void newstring(char *string){
- int i,j,x,newlength=0;
- char newstring[80];
- int length=(int)strlen(string);
- for(i=0, j=0; i<length; i++){
- if (!isspace(string[i])){
- newstring[j]=string[i];
- j++;
- newlength++;
- }else
- continue;
- }
- newstring[i]='\0';
- for(x=0; x<newlength; x++){
- printf("%c", newstring[x]);
- if (x==newlength)
- printf("%c\n", newstring[x]);
- }
- }
Add Comment
Please, Sign In to add comment