If the array is static it can declared in the structure itself:
struct myArrayTag
{
int num[12]; // array of 12 integers (e.g., 48 bytes).
} myArray;
If it is dynamic then you must use a pointer and allocate the array outside the structure. You should also maintain a variable in the structure to keep track of how many elements the array currently has:
struct myBufferTag
{
int * array; // Pointer to array of integers.
int size; // Size of array (number of elements);
} myBuffer;
Chat with our AI personalities
On some platforms (unix, for example) devices are handled as special files.
Every C plus plus program that is a main program must have the function 'main'.
Yes, you can use for-loop in a C program compiled by Turbo C.
A multidimensional array in C or C++ is simply an array of arrays, or an array of an array of arrays, etc. for however many dimensions you want. int a; // not an array int a[10]; // ten int a's int a[10][20]; // twenty int a[10]'s, or 200 int a's int a[10][20][30]; // and so on and so forth...
Arrays are not suitable for implementing queues because while they are ideal for adding to the end, the are not ideal for extraction from the beginning. For that you need a deque. Regardless, the STL (standard template library) already provides an efficient queue ADT in std::queue.