diff --git a/String/RemoveWhitespaceFromString.cpp b/String/RemoveWhitespaceFromString.cpp new file mode 100644 index 0000000..a9b012f --- /dev/null +++ b/String/RemoveWhitespaceFromString.cpp @@ -0,0 +1,17 @@ +#include +using namespace std; +void removeSpaces(char *str) +{ + int count = 0; + for (int i = 0; str[i]; i++) + if (str[i] != ' ') + str[count++] = str[i]; + str[count] = '\0'; +} +int main() +{ + char str[] = "just a sample"; + removeSpaces(str); + cout << str; + return 0; +} \ No newline at end of file