#return array
23 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
you need to either create it from outside the function and pass it to the function to fill it or allocate it inside your function and return a pointer
so to return a pointer all i have to do is just
return board;
?
it gives me a warning if i do that
how would i do that
in C you'd probably use malloc()
and theres no other way?
there are, but they're basically just different flavors of malloc
or passing in already-allocated memory as already suggested
is it because its a 2d array?
it's because an array inside your function will disappear when the function ends, so you can't use that to get the memory to return. So the memory needs to come from somewhere else, like malloc or from the caller
i think im gonna go back to python lol
alr ty ill figure it out
any reason you're doing C and not C++?
this ones for a course
im supposed to learn c before cpp
thas what my teacher told me
alright, good luck!
ty