User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 373,100 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,812 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser:
Views: 6610 | Replies: 4
Join Date: Sep 2004
Posts: 1
Reputation: hemant_is_here is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
hemant_is_here hemant_is_here is offline Offline
Newbie Poster

c language problm, how to pass pointer to a function

  #1  
Oct 1st, 2004
hi all
plz explain me with syntax "how to pass pointer to a function or pointers to a function " . plz tell me if there any big tutorial which can solve my problem providing a deep knowledge about it .
and one more probim :
what is incorrect int following program. this is a program to search a num in an array whose dimension and numbers are specified by user it is not running properly



#include<stdio.h>
int main()
{
int **a,r,c,i,j,re;
printf("enter dimensions of array rows and columns ");
scanf("%d%d",&r,&c);
a = (int**)malloc(r*sizeof(int*));
for(i = 0;i <=r-1;i++)
{a[i] = (int*)malloc(c*sizeof(int));
if(a == NULL||a[i] == NULL)
printf("memory not allocated ");}
for(i=0;i<=r-1;i++)
{
for(j=0;j<=c-1;j++)
{printf("enter element a_%d%d\t",i,j);
scanf("%d",&a[i][j]);
printf("%s\n",&a[i][j]);
}
printf("\n");
}
re = func(a,r,c);
if(re == 1)
printf("1");
else
printf("0");
return(0);
}
func(int *ptr,int row,int col)
{
int i,j,num,*k,count=0;
printf("enter number ");
scanf("%d",&num);
for(i=0;i<=row-1;i++)
{
for(j=0;j<=col-1;j++)
{
k = (ptr + i*col + j);
if(num ==*k);
{
printf("num = %d\tk =%d %d\t*k = %d ",num,k,(ptr + i*col + j),*k);
printf("\nnum %d found in %d th column of %d th row at position%d\n",num,i,j,i*col+j+1);
count+=1;
}
}
}
if(count!=0)
return(1);
else
return(0);
AddThis Social Bookmark Button
Reply With Quote  

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb C Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the C Forum

All times are GMT -4. The time now is 5:05 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC