c - strcpy Seg Fault -
according ddd i'm getting seg fault strcpy can't quite figure out i'm doing wrong (still quite new c). appreciated, in advance. int compare_people(person* first, person* second) { char firstname[32]; char secondname[32]; strcpy(firstname, first->name); strcpy(secondname, second->name); int returnval = strcmp(firstname, secondname); return returnval; } it seems either first or second equal null or first->name or second->name equal null or has non-zero terminated data due using strcpy exceeds 32 characters. other reason can first->name or second->name has invalid pointer example pointer local data destroyed. insert check in function. example assert( first != null && second != null && first->name != null && second->name != null && strlen( first->name ) < 32 && strlen( second->name ) < 32 ); or can split assert in several separate asserts...