As was suggested in an answer to my last question (How do I send an array of integers over TCP in C?), I tried to send an array of long int, however I may be doing something to break the solution...
#define ARRAY_LEN 4
/* I'm using long because the numbers are very large,
* but in this example they're small to save space. */
long originalArray[ARRAY_LEN] = { 1, 2, 3, 4 };
myObject.SetMyArray(originalArray);
// NOTE: The following is in a different function.
long *myArrayFromFunction = myObject.GetMyArray();
write(clientSocketFD, myArrayFromFunction, sizeof(myArrayFromFunction) * ARRAY_LEN);
Is converting to a pointer then passing incorrect?
When reading on the client side, instead of getting the numbers I sent (1, 2, 3, 4), I get long numbers such as 140088443806649...
#define ARRAY_LEN 4
long targetArray[ARRAY_LEN];
read(socketFD, targetArray, sizeof(targetArray) * ARRAY_LEN);
So, assuming that I need to read into a pointer, I tried this...
#define ARRAY_LEN 4
long *targetArray;
read(socketFD, targetArray, sizeof(targetArray) * ARRAY_LEN);
But this didn't work either (the read function returned -1).