I am currently trying to write a code that takes in a string and outputs that same string with no spaces. Everything in my code currently works, but the outputs don\'t delet
Strings are NULL
terminated, you should move that terminating NULL
to the new end of your string as well.
On a side note, you could do the whole thing in place (for ease in C code:)
#include
int main() {
char string1[100];
fgets (string1, 100, stdin);
char *inptr = string1; //could be a register
char *outptr = string1; //could be a register
do
{
if (*inptr != ' ')
*outptr++ = *inptr;
} while (*inptr++ != 0); //test if the char was NULL after moving it
fputs (string1, stdout);
}