I am concatenating a string (t) at the end of another string (s) in this code but stuck in the use of operators and their precedence in the loop ( while() )
1.
while(*s++);doesn't do the work2.
while(*s) ++s;does
But what is the difference between them ?
#include<stdio.h>
void strcat(char *, const char *);
int main(void){
char s[100] = "Aditya ";
char t[100] = "Kumar";
strcat(s, t);
printf("%s ", s);
return 0;
}
void strcat(char * s, const char * t){
while(*s)
s++;
while(*s++ = *t++);
}
Why in the strcat() function in first while while(*s++); doesn't concatenate the string but while(*s) s++; does I guess they work the same way ?
*sis evaluated and thens++?