Error: void value not ignored as it ought to be
I looked up this error online and most issues seemed to be associated with not returning anything, or putting the return statement in an if block. I do no such thing. What's going on?
*******IMPORTANT****** Even if I put this before the first if statement in the function, I still get the same error!
Code:
char *a = "lel";
return a;
FUNCTION:
Code:
char *list_groups(Group *group_list) {
Group * current = group_list;
char *groupList;
// What if there are no groups, do I have to strcpy an empty string?
if ((groupList = malloc(sizeof(char))) == NULL) {
perror("Error allocating space for the string groupList");
exit(1);
}
while (current != NULL) {
if ((groupList = realloc(groupList, sizeof(groupList) + sizeof(current->name) - 1)) == NULL) {
perror("Error resising the memory allocated to groupList");
exit(1);
}
strcat(groupList, strcat(current->name, "\n"));
current = current->next;
}
return groupList;
}
FUNCTION CALL:
Code:
char buffer;
//the above statement is not actually above the else if statement.
} else if (strcmp(cmd_argv[0], "list_groups") == 0 && cmd_argc == 1) {
buffer = list_groups(group_list);
printf("%c", buffer);