Currently having an issue where type casting a gid_t variable return from getgrnam() in c will allow for me to print the variable but I cannot pass it to a function that takes a char *. What would be the proper way to convert a gid_t to char * in c?
Here is example code of the issue where passing to add_util((char *)gid_num)
doesn't work but printing it works fine. When passed it causes a segmentation fault but passing it as add_util((char *)"1557")
works just fine.
char *group = (char *)"under";
struct group *record;
record = getgrnam(group);
char *gid_num = (char *)record->gr_gid;
printf("%s", gid_num) //works
add_util((char *)gid_num); //segfault