Closed highspeeder closed 6 years ago
Your last attempt returns a pointer to the CircularBuffer, which is not a char.
If you need a pointer to an element you can use
char c = chars[0];
pGet = &c;
If you intend to get access to the internal structure that is protected from external access: being a circular buffer there is no guarantee your first item precedes the second item in the internal structure...
By re-reading the title of the question I believe there's a misunderstanding: a circular buffer is a data structure, like an array or a linked list, but it's not an array and you cannot "cast" the circular buffer to an array. It internally uses an array, but that's an implementation detail which this library tries to hide as much as possible: otherwise why use the library... You can create an array with the content of the circular buffer though, by for-looping over the buffer and populating a properly sized array: I wonder if the circular buffer is the proper data structure in this case though
I set a pointer to fetch the address value of the buffer, and put the address value of the buffer. However, I get the following error: "The expression must be an lvalue or function specifier"
in code:
How can I get the address value of the buffer?
I tried changing the code as follows, but it also failed. :