Ok, I think you're getting some things jumbled.
You declare buf1 and buf2 as:
Therefore, you are declaring buf1 and buf2 as character arrays
You need to distinguish the underlying data types from what the data type represents
. I say that because I think you're getting confused by thinking that character arrays, character pointers, and strings are all synonymous--they aren't.
is an interpretation of underlying data. The compiler looks at a starting memory address, and "displays" each byte as a character until it reaches a byte with a value of 0 (the end-of-string marker).
A character pointer
is a variable that stores a memory address, and indicates that the memory it's addressing contains characters. But the pointer's value (the address itself) can be modified.
A character array
is a variable fixed at one memory address, with enough space available to store a fixed number of characters. For lack of a better analogy, think of it as a constant character pointer--the address cannot be modified.
Now, you can use both
a character pointer and
a character array whenever you need to supply a string to your code. And I think that might be part of what's tripping you up. A character array, with no subscript, is a pointer to the first element in the array. When you apply a subscript to an array, you're left with the character
value located at that index in the array.
With that out of the way...
is illegal for two reasons. First, as the compiler tells you, they are incompatible types. buf2 is a character array. buf1[i+1] is a character. Therefore, you are trying to assign a character to a character array.
Second, buf2 is a character array, and its location in memory cannot be modified. Therefore, any assignments to buf2 (without an appropriate subscript) will also result in an error.
I assume what you want is for buf2 to contain the same characters as buf1, from a given starting position. You should use the strcpy() or strncpy() functions for that purpose. You will need to use the address-of operator (&) that you touched on in your post to make this work correctly. For example:
strcpy( buf2, &buf1[i+1] )
If you want the "simplicity" of your original statement to work (buf2 = &buf[i+1]), then you will need to use a character pointer for buf2. Though, doing so might cause lots of grief if you are not familiar with all the pitfalls of working with pointers.