When I try to make "strcat" function for practice, I find some difference between 'for' loop with braces and without braces. But I have questions about the reason.
At first, my code is like
char strcat(char *ad,char *cp)
{
int i=0,j;
for(i;ad[i];i++) ///////////// here!!
for(j=0;ad[i]=cp[j];j++){
i++;
}
return ad;
}
In this code, 'strcat' doesn't work because of 'for' loop.
With curly-braces, it works.
I just learn "'for' loop works with curly-braces" by rote.
But when we translate 'for' to while
i=0
while(str[i])
i++;
We didn't use curly braces, but it works.
I want to know reason about this.