#include <iostream>
#include <algorithm> // for copy_if()
#include <cstring>
using namespace std;
void remove_extra_whitespaces(const char *input, char *output)
{
//output.clear(); // unless you want to add at the end of existing sring...
unique_copy (input, input+strlen(input)+1, output, [](char a,char b){ return isspace(a) && isspace(b);});
cout << output<<endl;
}
int main(int argc, char **argv)
{
cout << "testing 2 ..\n";
char input[0x255] = "asfa sas f f dgdgd dg ggg";
char output[0x255] = "NO_OUTPUT_YET";
remove_extra_whitespaces(input,output);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPiAgLy8gZm9yIGNvcHlfaWYoKQojaW5jbHVkZSA8Y3N0cmluZz4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnZvaWQgcmVtb3ZlX2V4dHJhX3doaXRlc3BhY2VzKGNvbnN0IGNoYXIgKmlucHV0LCBjaGFyICpvdXRwdXQpCnsKCS8vb3V0cHV0LmNsZWFyKCk7ICAvLyB1bmxlc3MgeW91IHdhbnQgdG8gYWRkIGF0IHRoZSBlbmQgb2YgZXhpc3Rpbmcgc3JpbmcuLi4KCXVuaXF1ZV9jb3B5IChpbnB1dCwgaW5wdXQrc3RybGVuKGlucHV0KSsxLCBvdXRwdXQsIFtdKGNoYXIgYSxjaGFyIGIpeyByZXR1cm4gaXNzcGFjZShhKSAmJiBpc3NwYWNlKGIpO30pOyAKCWNvdXQgPDwgb3V0cHV0PDxlbmRsOyAKfQoKaW50IG1haW4oaW50IGFyZ2MsIGNoYXIgKiphcmd2KQp7CiAgICBjb3V0IDw8ICJ0ZXN0aW5nIDIgLi5cbiI7CgogICAgY2hhciBpbnB1dFsweDI1NV0gPSAiYXNmYSBzYXMgICAgZiBmIGRnZGdkICBkZyAgIGdnZyI7CiAgICBjaGFyIG91dHB1dFsweDI1NV0gPSAiTk9fT1VUUFVUX1lFVCI7CiAgICByZW1vdmVfZXh0cmFfd2hpdGVzcGFjZXMoaW5wdXQsb3V0cHV0KTsKCiAgICByZXR1cm4gMDsKfQo=