accessing elements 2D array using pointers
C
#include<stdio.h>
//accessing elements of 2D array using pointers
int main(void){
int arr[4][4]={{1,2,3,4},{5,6,7,8},{9,0,1,2}};
int *ptr = &arr;
//accessing the elements of 2D array using ptr
for(int i=0;i<3;i++){
for(int j=0;j<4;j++)
printf("%d ",*((ptr+i*4)+j)); //4 is the number of columns
//*((ptr+i*4)+j) is similar to arr[i][j]
printf("\n");
}
return 0;
}
Also in C:
- Title
- a enum data type in c with loop
- Category
- C
- Title
- c check if file was created
- Category
- C
- Title
- how to convert int in to const char in c
- Category
- C
- Title
- windowns 10 allow ping
- Category
- C
- Title
- how to go to top of file in vim
- Category
- C
- Title
- Couldn't create temporary file to work with
- Category
- C
- Title
- binary tree geekd for geeks
- Category
- C
- Title
- factors using recursion
- Category
- C
- Title
- debian install npm
- Category
- C
- Title
- left me on read
- Category
- C
- Title
- how to put quotes inside string c
- Category
- C
- Title
- disable gnu++11 option
- Category
- C
- Title
- arduino digital read
- Category
- C
- Title
- sue murry
- Category
- C
- Title
- conda windows 10 from pip._internal.cli.main import main ModuleNotFoundError
- Category
- C
- Title
- infinite loop using while
- Category
- C
- Title
- text wrap terminal colour
- Category
- C
- Title
- c zero out array
- Category
- C
- Title
- Switch Mode C Programming
- Category
- C
- Title
- vbl share price
- Category
- C
- Title
- CL/cl.h: No such file or directory
- Category
- C
- Title
- how to get random numbers in c
- Category
- C
- Title
- Declare macro
- Category
- C
- Title
- how to sleep in c
- Category
- C
- Title
- triangulo
- Category
- C
- Title
- read from stdin c
- Category
- C
- Title
- how to write function in c
- Category
- C
- Title
- oop244
- Category
- C
- Title
- variadic function in c
- Category
- C
- Title
- printf in c
- Category
- C
- Title
- add border to image android
- Category
- C
- Title
- restapi
- Category
- C
- Title
- functions return type in c
- Category
- C
- Title
- c value set to zero __memmove_avx_unaligned_erms
- Category
- C
- Title
- es vocal
- Category
- C
- Title
- Fibonacci program c pthread
- Category
- C
- Title
- concatenate two strings in c
- Category
- C
- Title
- -> operator
- Category
- C
- Title
- error: dereferencing pointer to incomplete type
- Category
- C
- Title
- ImportError: No module named 'skimage'
- Category
- C
- Title
- last element from list javascript
- Category
- C
- Title
- how to pass an array to a thread in c?
- Category
- C
- Title
- what is stdin in c
- Category
- C
- Title
- how to free memory in c
- Category
- C
- Title
- c bit access union
- Category
- C
- Title
- incompatible types when initializing type ‘float’ using type ‘point {aka struct point}’
- Category
- C
- Title
- how to store a user input with spaces in c
- Category
- C
- Title
- what is strikethrough in markdown
- Category
- C
- Title
- prime number
- Category
- C
- Title
- resto de division recursiva
- Category
- C
- Title
- #include<stdlib.h>
- Category
- C
- Title
- networkx remove attributes
- Category
- C
- Title
- compare two chars c
- Category
- C
- Title
- print variable c
- Category
- C
- Title
- linux directory commands
- Category
- C
- Title
- malloc in c
- Category
- C
- Title
- mongodb delete all documents
- Category
- C
- Title
- how to call the tkinter insert command from another class
- Category
- C
- Title
- pi in c language
- Category
- C
- Title
- pointer parameter where to put the asterix in C?
- Category
- C
- Title
- arduino digital io pins
- Category
- C
- Title
- coin row problem in linear time
- Category
- C
- Title
- c struct
- Category
- C
- Title
- does strcat null terminate
- Category
- C
- Title
- function in c
- Category
- C
- Title
- reset style matplotlib
- Category
- C
- Title
- change a attribute in dataframe
- Category
- C
- Title
- measure time in c
- Category
- C
- Title
- d3 box shadow
- Category
- C
- Title
- set timezone in debian terminal
- Category
- C
- Title
- how to create an array of char in c++
- Category
- C
- Title
- c string concatenation with int
- Category
- C
- Title
- what is restrict keyword in c
- Category
- C
- Title
- tmux how to kill all sessions
- Category
- C
- Title
- if statement shorthand c
- Category
- C
- Title
- hopw to check how many duplicates in an array c
- Category
- C
- Title
- bash: apt-add-repository: command not found
- Category
- C
- Title
- print in c
- Category
- C
- Title
- confirm sweet alert
- Category
- C
- Title
- assert() in c
- Category
- C
- Title
- bella ciao lyrics
- Category
- C
- Title
- lelcetric fied
- Category
- C
- Title
- strtok
- Category
- C
- Title
- múltiplos entre dos numeros en c
- Category
- C
- Title
- c program to find the sum of given number
- Category
- C
- Title
- passing 2d array as parameter to function in c
- Category
- C
- Title
- potencia recursiva
- Category
- C
- Title
- version of libgcc
- Category
- C
- Title
- how can i remove a specific item from an array
- Category
- C
- Title
- qtableview get selected row
- Category
- C
- Title
- scanf read line
- Category
- C
- Title
- how to make a linked list in c
- Category
- C
- Title
- c print hello world
- Category
- C
- Title
- c array
- Category
- C
- Title
- File "h5py\h5g.pyx", line 161, in h5py.h5g.create ValueError: Unable to create group (name already exists)
- Category
- C
- Title
- csrf_exempt
- Category
- C
- Title
- passing 'const char *' to parameter of type 'char *' discards qualifiers
- Category
- C
- Title
- reverse function in c
- Category
- C
- Title
- code: 'EADDRINUSE', [0] errno: 'EADDRINUSE', [0] syscall: 'listen', [0] address: '::', [0] port: 5000
- Category
- C
- Title
- java.lang.SecurityException: Permission denied (missing INTERNET permission?)
- Category
- C