#include <iostream>
#include <string> // forget about char[] and char*: use string instead !
#include <algorithm> // for copy_if()
#include <iterator> // for the back_inserter
using namespace std;
void remove_extra_whitespaces(const string &input, string &output)
{
output.clear(); // unless you want to add at the end of existing sring...
unique_copy (input.begin(), input.end(), back_insert_iterator<string>(output), [](char a,char b){ return isspace(a) && isspace(b);});
cout << output<<endl;
}
int main(int argc, char **argv)
{
cout << "testing 2 ..\n";
string input = "asfa sas f f dgdgd dg ggg";
string output = "NO_OUTPUT_YET";
remove_extra_whitespaces(input,output);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPiAgICAgLy8gZm9yZ2V0IGFib3V0IGNoYXJbXSBhbmQgY2hhcio6IHVzZSBzdHJpbmcgaW5zdGVhZCAhICAKI2luY2x1ZGUgPGFsZ29yaXRobT4gIC8vIGZvciBjb3B5X2lmKCkKI2luY2x1ZGUgPGl0ZXJhdG9yPiAgIC8vIGZvciB0aGUgYmFja19pbnNlcnRlcgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdm9pZCByZW1vdmVfZXh0cmFfd2hpdGVzcGFjZXMoY29uc3Qgc3RyaW5nICZpbnB1dCwgc3RyaW5nICZvdXRwdXQpCnsKCW91dHB1dC5jbGVhcigpOyAgLy8gdW5sZXNzIHlvdSB3YW50IHRvIGFkZCBhdCB0aGUgZW5kIG9mIGV4aXN0aW5nIHNyaW5nLi4uCgl1bmlxdWVfY29weSAoaW5wdXQuYmVnaW4oKSwgaW5wdXQuZW5kKCksIGJhY2tfaW5zZXJ0X2l0ZXJhdG9yPHN0cmluZz4ob3V0cHV0KSwgW10oY2hhciBhLGNoYXIgYil7IHJldHVybiBpc3NwYWNlKGEpICYmIGlzc3BhY2UoYik7fSk7ICAKCWNvdXQgPDwgb3V0cHV0PDxlbmRsOyAKfQoKaW50IG1haW4oaW50IGFyZ2MsIGNoYXIgKiphcmd2KQp7CiAgICBjb3V0IDw8ICJ0ZXN0aW5nIDIgLi5cbiI7CgogICAgc3RyaW5nIGlucHV0ID0gImFzZmEgc2FzICAgIGYgZiBkZ2RnZCAgZGcgICBnZ2ciOwogICAgc3RyaW5nIG91dHB1dCA9ICJOT19PVVRQVVRfWUVUIjsKICAgIHJlbW92ZV9leHRyYV93aGl0ZXNwYWNlcyhpbnB1dCxvdXRwdXQpOwoKICAgIHJldHVybiAwOwp9Cg==