Working with matrix

dkn

Joined
Feb 24, 2022
Messages
1
Reaction score
0
To show matrix M
void showV(int vv[])
{ int nn, i;
nn=sizeof(vv)/sizeof(int);
for(i=0; i<nn; i++) printf("%d, ", vv);
return;
}
void showM(int mm[][])
{ int i;
nn=sizeof(M)/sizeof(int);
for(i=0; i<nn; i++) showV(mm);
}

What's wrong ??
Thnx
DuyKy
 
Joined
Mar 3, 2021
Messages
240
Reaction score
30
There's a few reasons this won't work. Or even compile. nn isn't declared in showM. In your print statements, you're not using your loop/index variables. Lastly, sizeof will not work on array arguments like that in C 'cause the compiler has NO idea how large they actually are. You'll most definitely have to pass in the number of rows and columns to the functions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top