Here is a function that will do what you need.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void RemoveWhiteSpace(char *p);
int main(void)
{
char str[51];
strcpy(str, "Remove\t\tall white space\n and new lines\t\n");
RemoveWhiteSpace(str);
printf("(%s)\n", str);
strcpy(str, " \t\n");
RemoveWhiteSpace(str);
printf("(%s)\n", str);
strcpy(str, "");
RemoveWhiteSpace(str);
printf("(%s)\n", str);
return 0;
}
void RemoveWhiteSpace(char *p)
{
char *t;
while (*p)
{
// modify this line to include other characters to remove
if (*p == '\t' || *p == '\n')
{
t = p; // use temp pointer to skip over all selected characters
while (*t)
{
*t = *(t + 1);
t++;
}
}
else
{
p++;
}
}
}