Originally Posted by
jimblumberg
Show your current code.
Look up the documentation for the functions you're using and be sure to include the proper include files.
Jim
Code:
#include <stdio.h>#include <stdlib.h>
#define TEST_ARRAY_SIZE 100
int define_array(int **new_ptr)
{
*new_ptr = malloc(sizeof(int) * TEST_ARRAY_SIZE);
int array_size = 3;
(*new_ptr)[0] = 40;
(*new_ptr)[1] = 50; // prints garbage
(*new_ptr)[2] = 20; // prints garbage
printf("%d\n%d\n%d", *new_ptr[0], *new_ptr[1], *new_ptr[2]);
return array_size;
}
int main ()
{
int *local_ptr = NULL;
define_array(&local_ptr);
return 0;
}
Ive included stdlib and stdio. Those are the only two libraries I need