I'm still learning C, but I'm trying to make sure I've got a decent grasp on working with strings and data structures.If possible, I'd like a little input on how I'm handling this and see ifit could be done more efficientlyI'm setting myself up for unforeseen negative consequencesI'm using the functions appropriatelyvoid test(char *username, char *password) {    printf(Checking password for %s - pw: %s\n,username,password);    char *query1 = SELECT password FROM logins WHERE email = ';    char *query2 = ' LIMIT 1;    char *querystring = malloc(strlen(query1) + strlen(username) + strlen(query2) * sizeof(char));    strncpy(querystring,query1,strlen(query1));    strncat(querystring,username,strlen(username));    strncat(querystring,query2,strlen(query2));    printf(Query string: %s\n,querystring);    mysql_query(mysql_con,querystring);    MYSQL_RES *result = mysql_store_result(mysql_con);    int num_fields = mysql_num_fields(result);    int num_rows = mysql_num_rows(result);    if (num_rows != 0) {        MYSQL_ROW row;        printf(Query returned %i results with %i fields\n,num_rows,num_fields);        row = mysql_fetch_row(result);        printf(Password returned: %s\n,row[0]);        int comparison = strncmp(password, row[0], strlen(password));            if (comparison == 0) {                printf(Passwords match!\n);            } else {                printf(Passwords do NOT match!\n);            }            }    else {        printf(No such user... Password is invalid);    }        free(querystring);}Output of program:Checking password for test@blah.com - pw: 5f4dcc3b5aa765d61d8327deb882cf99Query string: SELECT password FROM logins WHERE email = 'test@blah.com' LIMIT 1Query returned 1 results with 1 fieldsPassword returned: 5f4dcc3b5aa765d61d8327deb882cf99Passwords match!
Efficiency with strcpy, strcat and malloc
beginner;c;strings;mysql;authentication