Having some serious trouble

You might also check out the Serial method named:

Serial.readBytesUntil(character, buffer, length)

A common use is to read serial data from the Serial object until the user presses Enter. When that happens, a newline character ('\n') is sent, signaling the end of input. If the longest message is, say, 15 bytes, then:

char myArray[16];   // Need an extra byte for the null character
int numberRead;
// More of your code...

   numberRead = Serial.readBytesUntil('\n', myArray, 15);
   myArray[numberRead] = '\0';
// more code??
   return atol(myArray);
// the rest of your code

This fragment would keep reading the input stream until the newline is read after the user pressed the Enter key. It will read no more than 15 characters. The method returns the number of bytes actually read, so the next statement places a null character at the end of the input stream so you can treat it as a string. You could then use the standard library atol() to convert the ASCII characters to a long.