Code: C
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<malloc.h>
char *spacedel(char *a)
{
char *b;
int i, j, c=0, l=strlen(a);
for(i=0;i<l;i++)
{
if(*(a+i)==' ')
c++;
}
b=(char *)malloc((l-c)*sizeof(char));
i=0;
j=0;
while(i<l && j<(l-c))
{
if(*(a+i)==' ')
i++;
else
{
*(b+j)=*(a+i);
i++;
j++;
}
}
return(b);
}
void main()
{
char a[]="C is the philosophy of life.";
char *b;
b=spacedel(a);
printf("\n%s", b);
getch();
}
Immediately after this I was given an assignment to retreat the sentence, I mean say the sentence initially given was...
Code:
C is the philosophy of life.
Code:
Cisthephilosophyoflife.
How on the earth am I gonna do that???????

Please help....I am getting confused even in tracing out my process....



