- #1
xortan
- 78
- 1
I am trying to write a function that will detect multiple spaces, tabs, and newlines and replace it with a single string. Here is what I got so far, I keep getting errors about using a void expression and making an integer from a pointer without a cast. Please help I am really new to programming.
void compress(char* s);
int main()
{
char a[] = "Hello World";
printf("%s", compress(a));
getchar();
}
void compress(char* s)
{
char *srcIx = s;
char *destIx;
while(*srcIx)
{
if(*srcIx != ' ' || *srcIx != '\t' || *srcIx != '\n')
*(destIx++) = *srcIx;
srcIx++
}
*s = destIx;
}
Am I even going about this problem the right way? Also when I enter a bunch of spaces into the box PF seems to compress it already :P Imagine there are a bunch of spaces between hello and world
void compress(char* s);
int main()
{
char a[] = "Hello World";
printf("%s", compress(a));
getchar();
}
void compress(char* s)
{
char *srcIx = s;
char *destIx;
while(*srcIx)
{
if(*srcIx != ' ' || *srcIx != '\t' || *srcIx != '\n')
*(destIx++) = *srcIx;
srcIx++
}
*s = destIx;
}
Am I even going about this problem the right way? Also when I enter a bunch of spaces into the box PF seems to compress it already :P Imagine there are a bunch of spaces between hello and world