The key to this question is to understand the for statement and when the IF statement ends.
for (i=j=0;str[i]!='\0',i++)
if(str[i]!='c')
s[j++]=s[i];
s[j]=0;
#include <stdio.h>
void fun(char *s)
{
int i, j;
for (i=j = 0; s[i] != '\0'; i++)
if (s[i] != 'c')
/************found************/
s[j++] = s[i];
s[j] = 0;
void fun(char *s)
{
int i, j;
for (i=j = 0; s[i] != '\0'; i++)
if (s[i] != 'c')
/************found************/
s[j++] = s[i];
s[j] = 0;
/************found************/
}
void main()
{
char s[80];
printf("enter a string: "); gets(s);
printf("the original string: "); puts(s);
fun(s);
printf("the string after deleted : "); puts(s); printf("\n\n");
}
}
void main()
{
char s[80];
printf("enter a string: "); gets(s);
printf("the original string: "); puts(s);
fun(s);
printf("the string after deleted : "); puts(s); printf("\n\n");
}