Champions of the Gods: Forums Register | Help | Log In |
Register Portal Member List Guild Roster World Clock Games Chat [0] View New Posts View Today's Posts Search

Current time: 09-06-2010, 10:36 PM Hello There, Guest! (Login — Register)

Champions of the Gods: Forums / General / Applications / C - function declearation

Post Reply 
Threaded Mode | Linear Mode
C - function declearation
01-08-2010, 07:37 AM
Post: #1
gabriellamberd Offline
Junior Member
*
Posts: 3
Joined: Jan 2010
Reputation: 0
MyMood: None
C - function declearation
Hi Guys,

I have written the program for accesssing elements of 2D array using pointer to array of int which is as below:

void display(int (*)[4], int , int);

int main()
{
int a[2][4] = {{1,2,3,4},
{5,6,7,8}
};

display(a, 2, 4); // this line is giving error

getch();
}

void display(int (*ptr)[4], int row, int col)
{

int i, j;
int *p;

for(i = 0; i < row; i++)
{
p = ptr + i;
for( j= 0; j < col; j++)
{
printf("%d ", *(p+j));
}
printf("\n");
}
}

But the function declearion line is giving the error and also I am not sure about function prototype written correct or not.

Please help me in how the function prototype and declearation has to be written for the above fucntion defination.

Thanks

r4 dsi
Find all posts by this user
Quote this message in a reply
« Next Oldest | Next Newest »
Post Reply 


  • View a Printable Version
  • Send this Thread to a Friend
  • Subscribe to this thread
Forum Jump:

Current time: 09-06-2010, 10:36 PM

Contact Us | Champions of the Gods | Return to Top | Return to Content | Lite (Archive) Mode | RSS Syndication

Powered By MyBB, © 2002-2010 MyBB Group.
Theme created by IncadudeF