So I am trying to figure out a way to print a string without spaces and it is not working for some reason, whenever I enter in a string to the program it ends out printing nothing.
#include <stdio.h>
char *removeSpaces(char *inString);
int main() {
char str1[50];
printf("Enter a string : ");
scanf("%s", &str1);
removeSpaces(str1);
}
char *removeSpaces(char *inString) {
char str2[50];
int j = 0;
for (int i = 0; i < 50; i++) {
if (inString[i] != ' ') {
str2[j] = inString[i];
j++;
}
}
for (int i = 0; i < 50; i++) {
printf("%s", str2[i]);
}
}