I can\'t figure out this expression:
str + n
where char str[STRING_LENGTH] and int n.
I have worked a lot
str can be regarded as pointing to the memory address associated with a character sequence of length STRING_LENGTH. As such, c pointer arithmetic is being exploited in your statement str + n. What is is doing is pointing to the memory address of the nth character in the character sequence.
It's pointer arithmetic. For instance:
char* str = "hello";
printf("%s\n", str + 2);
Output: llo. Because str + 2 point to 2 elements after str, thus the first l.
Yes ans of @Yu Hao and @Bathsheba are correct.
But if you want to do the concatenation, you can go as following code snippet.
char string[]="hello";
int number=4;
char cated_string[SIZE_CATED_STRING];
sprintf(cated_string,"%s%d",string,number);
printf("%s",cated_string);
Happy Coding.