I have an array of characters name "mess_in" and I would like to assign this to a char* pointer. I attempted using strncpy() but am not sure if this is correct. When I run it once this seems to work correctly but subsequent calls do not seem to be copying the right data. Here is my code:
Code:
/*Assign memory for each of the variables as needed*/
request = malloc(BUFSIZ);
temp = malloc(256);
/*Read in the HTTP request from the client*/
if( (nr=read(socket, mess_in, BUFSIZ) ) < 0) {
fprintf(stderr, "Trouble Reading From Client.\n");
fprintf(stderr, "Errno Value: %s\n", strerror(errno));
return -1;
}
/*Copy the buffer into the request variable*/
strncat(request, mess_in, strlen(mess_in));