error is on Line 12 - please read the man pages on strcpy()
the requirement is that the first argument must have its space already allocated, but if you trace back the variable receivedString, it goes all the way back to Line 24 which is a char* which hasn't been initialized!!!
if you use your code in your OP and change Line 24 to:
1 2
|
char carray[80]; // needs to be big enough to take in Line 4's "defined" or anything you put there
char *strToBeAssignedInFun = carray; // initialize character pointer
|
it should run with that change - I haven't tried your code with this fix yet so I'm assuming there are no other bugs in your code
btw, you can mix C character arrays, char* and C++ strings as much as you like, but make sure you know what you are doing
also, you may consider using strdup() instead of strcpy() if you are worried about assigning a fixed array to strToBeAssignedInFun, but if you do use strdup(), you must remember to free()