Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- //#include <stdlib.h>
- //#include <stdio.h>
- using namespace std;
- void collectors(char *str, int n) {
- for(int i = 0; i < n; i++) {
- if(str[i] != ' ') {
- break;
- }
- if(str[i] == ' ') {
- int k = 0;
- for(int i = 0; str[i] == ' '; i++) {
- if(str[i] == ' ') {
- k++;
- }
- }
- for(int i = 0; i < n; i++) {
- str[i] = str[i + k];
- }
- }
- }
- cout << "Result:" << str << endl;
- }
- int main()
- {
- const int n = 999;
- char str[n];
- int i;
- cout << "Enter string:";
- //gets(str);
- cin.get(str, n);
- cout << "Entered string:" << str << "\n";
- collectors(str, n);
- }
Add Comment
Please, Sign In to add comment