Im trying to remove a space from an array and for whatever reason
I get the string doubled when I call the function.
In the function itself I have the right result.
Code:#include <iostream> using namespace std; void DelChar(char *src) { char buf[260]; int i =0; while (*(src) != '\0') { if (*(src) != ' ') { buf[i] = *(src); i++; } src++; } buf[i] = '\0'; strcpy(src,buf); cout << "-> " << src << endl; return; } int main() { char text[260] = "he llo"; DelChar(text); cout << text << endl; return 0; }