There are two main problems.
1. char *neww[100];
isn't an array of chars, nor even a simple char pointer.
It's an array of pointers.
2. You can't return a pointer to a local variable
This is your 3rd error message.
The usual means of getting a string result is to pass in the output string pointer as a parameter, like so.
Code:
#include<stdio.h>
#include<string.h>
void rmDataForDBmarker(char *stringToClean, char *whatToRemove, char *answer);
int main()
{
char logToKeep[] = "mdata,"; // this is the key word of the log entry to keep
char *logFinder = "mdata,b1a571,3324 d,123.46,987.99";
char dataMarkerRmvd[100] = {};
printf("string before the function: %s\n", logFinder);
rmDataForDBmarker(logFinder, logToKeep, dataMarkerRmvd);
printf("back from rmDataForDBmarker(): dataMarkerRmvd = %s\n", dataMarkerRmvd);
}
void rmDataForDBmarker(char *stringToClean, char *whatToRemove, char *answer){ // in this case
printf("Now the code is in the function...\n");
printf("The next stringToClean is = %s\n", stringToClean);
char *p = strstr(stringToClean, whatToRemove);
if ( p ) {
p += strlen(whatToRemove); // get to the end of the marker
strcpy(answer,p); // copy to the answer
}
}
Code:
$ gcc foo.c
$ ./a.out
string before the function: mdata,b1a571,3324 d,123.46,987.99
Now the code is in the function...
The next stringToClean is = mdata,b1a571,3324 d,123.46,987.99
back from rmDataForDBmarker(): dataMarkerRmvd = b1a571,3324 d,123.46,987.99
It's usual for the newlines to be at the end of printf strings, not at the beginning.