[algogeeks] 2 Dim array as parameter

2012-06-06 Thread Ashish Goel
Hi,

traditional C style of passing 2D array to a C func is for example, void
func(char **pArr, int m, int n).
Like we validate a pointer before accessing it if it is valid, how do we
verify that the array provided indeed has got memory allocated to it before
accessing it


Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] 2 Dim array as parameter

2012-06-06 Thread Abhishek Sharma
check the return value of malloc.
on success,it returns the pointer to that memory
on error, it returns NULL
..
if( (char*)malloc(10)==NULL)
{
printf(Not Enough memory available);
exit(1);
}


On Wed, Jun 6, 2012 at 7:20 PM, Ashish Goel ashg...@gmail.com wrote:

 Hi,

 traditional C style of passing 2D array to a C func is for example, void
 func(char **pArr, int m, int n).
 Like we validate a pointer before accessing it if it is valid, how do we
 verify that the array provided indeed has got memory allocated to it before
 accessing it


 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Abhishek Sharma
Under-Graduate Student,
PEC University of Technology

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.