I want to pass a 2D matrix to a function in C which modifies the elements of the matrix and the modifications should be effective in the calling function.
How to achieve this in C.
venuaccha
19
Newbie Poster
Recommended Answers
Jump to PostAll arrays, including multi-deminensional arrays, are passed by address, never by value. Passing a 2d array is similar to 1d array, the sedond deiminsion is optional.
void foo(int array[10][10]) { // blabla } or void foo(int array[10][]) { // blabla } int main() { int array[10][10]; // …
All 4 Replies
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
venuaccha
19
Newbie Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Salem
5,138
Posting Sage
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.