answersLogoWhite

0

WAP mean Wireless Application Protocol or Wireless Access Point, depending on the context. WAP has no meaning with respect to arrays. I assume you are asking how to access a 2D array through pointers. The follow program shows one method of printing a 2D array of type int of any length:

#include<stdio.h>

// print 2D array of type int:

void print_array (int* arr, size_t rows, size_t cols) {

for (size_t elem=0; elem<rows*cols; ++elem) {

printf ("%d\t", arr[elem]);

if ((elem+1)%cols==0) printf ("\n");

}

}

int main (void) {

const size_t rows = 3;

const size_t cols = 4;

int x[rows][cols] = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}};

print_array (&x[0][0], rows, cols);

return 0;

}

User Avatar

Wiki User

9y ago

What else can I help you with?

Related Questions

Difference between 1D array and 2D arrays?

1d array contains single row and multiple columns and 2d array contains multiple row and multiple columns. 2d array is a collection of 1d array placed one below another,while 1d array is simple a collection of elements.


Flow chart of multiplication of 2d array?

algorithm &amp; flowchrt of 2d matrices


Is there any overhead issues if you make a 2D array arr28 rather than making a 1D array arr16 of size 16 Any memory issues or execution differences between the two?

2D array of size 2x8 and 1D array of size 16


Subtraction of 2d array in java?

looda le lo mera


What is the program of 2d array in gw basic?

In GW-BASIC, a 2D array can be declared using the DIM statement, specifying the number of rows and columns. For example, DIM A(5, 5) creates a 2D array named A with 6 rows and 6 columns (indexing starts from 0). You can access and manipulate elements using syntax like A(row, column). Here's a simple example: A(1, 1) = 10 assigns the value 10 to the element in the second row and second column of the array.


How do you pass a 2D array in a functions?

if you were to call a function you would write it as: function(array[][], int pretend, double pretend2); arrays will always be passed by reference, not by value.


How do you access 2D array elements by using single variable?

int main() { int array[3][3]; int i; for(i=0; i &lt;9;i++) { printf("the element is %d\n", array[i/3][i%3]); } return 0; }


How do you Assign an address to an element of pointer array?

Pointers were always difficult subject to understand. I would suggest to read several tutorials and spend some time playing with them. Explanation: /* create array of two pointers to integer */ int *aaa[2]; /* setting first pointer in array to point to 0x1212 location in memory */ aaa[0] = (int *)0x1212; /* allocate memory for the second pointer and set value */ aaa[1] = malloc(sizeof(int)); *aaa[1] = 333; /* if you want to can make first item to point to the second, now arr[0] pointer address changed to the same as aaa[1] pointer */ aaa[0] = aaa[1]; /* print aaa[1] address and later print value */ printf("LOCATION: %X\n", (unsigned int)*(aaa + 1)); printf("VALUE: %d\n", **(aaa + 1)); /* exact the same here, but different way of how I wrote pointers */ printf("LOCATION: %X\n", (unsigned int)aaa[1]); printf("VALUE: %d\n", *aaa[1]); If you would do the same with 0 element of array, which points to 0x1212 memory location you would get some kind of number or Bus error if you accessed restricted memory place (for example the beginning of memory). I hope this I did not make you more confused than you are.


What is the most efficient way to find the longest palindrome subsequence in Java?

One efficient way to find the longest palindrome subsequence in Java is by using dynamic programming. This involves creating a 2D array to store the lengths of palindrome subsequences for different substrings of the input string. By iterating through the string and filling in the array based on the palindrome properties, you can determine the longest palindrome subsequence.


Would there be any Memory issues or execution issues or any merits or demerits of using 1D array of size 'mn' instead of using 2D array of size mxn?

It requires the same amount of memory, so it wouldn't spare anything. Don't do it.


Why would you use a pointer to pointer a in aprogram?

A pointer to pointer has many uses, one of the simplest being 2D arrays (matrices). Compacting garbage collectors also often employ pointer pointers.


How do you make a arrays of 18 pictures?

To create an array of 18 pictures, you first need to load the images into your programming environment. For example, in Python, you can use libraries like NumPy or PIL to handle the images. You can then create a list or a NumPy array and append or reshape the images into that structure, ensuring that each picture is stored in a consistent format, such as a 2D array for grayscale images or a 3D array for RGB images. Finally, you can manipulate or display the array as needed.