From 514dcd4dec8218b099d3f6f3e6dc270a7d4b8dcf Mon Sep 17 00:00:00 2001 From: samsy12 Date: Mon, 12 Oct 2020 00:44:52 +0530 Subject: [PATCH] added new program --- String/RemoveWhitespaceFromString.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 String/RemoveWhitespaceFromString.cpp 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