I keep getting the following warning with this code:
warning: assignment makes pointer from integer without a cast
Referring to the line containing the strndup function call. The strndup function is copying the string but it is copying the whole string.
I am not sure what I am doing wrong, help would be great.
Code:
char *inet;
char *str;
char *field_delimeter;
char received[BUFSIZ] = "blah blah ( copy me ) blah";
// Get delimeters
str = strchr( received, '(' );
field_delimeter = strrchr( received, ')' );
// Get new string
if (( inet = strndup( str, field_delimeter - str))== NULL){ // this line returns warning
printf( "error duping string\n" );
return EXIT_FAILURE;
}