Hey, I need to make a function that returns an array. How would I do so? And how would I make a variable that gets all the values in that function? Thanks, you guys :)
glut 0 Light Poster
Recommended Answers
Jump to Post#include "stdio.h" #include "stdlib.h" int* someFunction(void) { int* array; array = (int*)malloc(100 * sizeof(int)); array[0]=10; array[1]=54; return array; }; int main() { int* array = someFunction(); printf("%i %i", array[0], array[1]); free(array); return 0; }
or in C++...
#include <iostream> int* someFunction() { int* array …
All 3 Replies
Reply to this topic 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.