-3
#include<stdio.h>
#include<conio.h>
void** printA( int*  , int ,int[][]);
void printw(void*, int ,int);
void main()
{

int num[3][5] = {
{1, 2,3,4,5},
{6,7,8,9,10},
{11,12,13,14,15},
};

int* num_ptr[3];
void** ptr;
printf("traversing by double pointer");
ptr=printA(*num_ptr,3, num);
printw(* ptr, 3, 5);
}
void** printA(int* num_ptr[],int r,int num)
{
   int i,j;
   for(i=0;i<r;i++)
   {
      *num_ptr[i]=num[i][0];

   }
   return ** arrp[0];
}

void printw(void * ptr, int r, int c)
{
   int i,j;
   for(j=0;j<r;j++)
   {
      for(i=0;i<c;i++)
      {
         printf("%d",(int)**ptr[j]);
         *ptr++;
      }
   }
}

Edited by WaltP: Added CODE Tags

Votes + Comments
Come back when you've learnt to read the forum RULES
2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by priyankapandey
0

hi all...I am actually trying to retrieve a 2 Dimensional array, by passing it to a function, which returns a pointer to the array.
I want to print the array using pointers only....

#include<stdio.h>
#include<conio.h>
void** printA( int*  , int ,int[][]);
void printw(void*, int ,int);
void main()
{

int num[3][5] = {
{1, 2,3,4,5},
{6,7,8,9,10},
{11,12,13,14,15},
};

int* num_ptr[3];
void** ptr;
printf("traversing by double pointer");
ptr=printA(*num_ptr,3, num);
printw(* ptr, 3, 5);
}
void** printA(int* num_ptr[],int r,int num)
{
   int i,j;
   for(i=0;i<r;i++)
   {
      *num_ptr[i]=num[i][0];

   }
   return ** arrp[0];
}

void printw(void * ptr, int r, int c)
{
   int i,j;
   for(j=0;j<r;j++)
   {
      for(i=0;i<c;i++)
      {
         printf("%d",(int)**ptr[j]);
         *ptr++;
      }
   }
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.