I basically want to the C of equivalent of this (well, just the part with the array, I don\'t need the class and string parsing and all that):
public class E
/* We include the following to get the prototypes for:
* malloc -- allocates memory on the freestore
* free -- releases memory allocated via above
* atoi -- convert a C-style string to an integer
* strtoul -- is strongly suggested though as a replacement
*/
#include
static int *foo;
int main(int argc, char *argv[]) {
size_t size = atoi(argv[ 1 ]); /*argv[ 0 ] is the executable's name */
foo = malloc(size * sizeof *foo); /* create an array of size `size` */
if (foo) { /* allocation succeeded */
/* do something with foo */
free(foo); /* release the memory */
}
return 0;
}
Caveat:Off the cuff stuff, without any error checking.