Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int size=80;
- char str[size];
- int index=0;
- char ch=0,lastChar=0;
- printf("enter your string(80 chars)\n");
- for(int i=0;i<(size-1);i++)/*room for our null byte*/
- {
- ch=getchar();
- if(ch == EOF || ch == '\n')
- break;
- if(ch == ' ' && lastChar== ' ')
- continue;
- lastChar = ch;
- str[index] = ch;
- index++;
- }
- /*fix null byte*/
- str[index] = '\0';
- printf("%s\n",str);
Add Comment
Please, Sign In to add comment