#include<stdio.h>
void fun(int (*ptr)[4]) {
for(int i = 0; i<=2; i++) {
printf("Address of i block of arr %p\n", ptr + i);
for(int j = 0; j<=3; j++) {
printf("arr[%d][%d] = %d\n",i,j,*(*(ptr + i) + j) );
}
}
};
int main() {
int arr[3][4] = {
{11, 12, 13, 14},
{15, 16, 17, 18},
{19, 20, 21, 22}
};
int (*ptr)[4] = arr;
fun(ptr);
return 0;
}
Monday, November 29, 2021
Passing 2D Array to a function (2D Array Haua nahi hai normal array ki tarah he behave karta hai)
Subscribe to:
Post Comments (Atom)
Priority queue deleting elements after ascending inputs Gaand Fadd
using namespace std; #include<iostream> #define N 5 class pq { public: int* arr; int front; int rear; pq() { ...
-
using namespace std; #include<stdio.h> #define N 5 class q{ public: int* arr; int front; int rear; q() { ...
-
#include<stdio.h> int fnCmp(char* str1, char* str2) { while( (*str1 != '\0' && *str2 != '\0') && ...
-
#include<stdio.h> void fncpy(char* str2, char* str1) { int i = 0; while(*str1 != '\0') { str2[i] = *str1; ...
No comments:
Post a Comment