Click here to Skip to main content
15,881,089 members

Comments by M@gelearn (Top 42 by date)

M@gelearn 22-Mar-21 12:09pm View    
Just one more thing to add, just because I did not see it in your code, this doesn't mean you didn't know it and I'm sure you forgot to free the memory at the end.
I just did this before the function ended free(usernames);
M@gelearn 22-Mar-21 12:04pm View    
Ohh.. that's awesome.. :)
Thanks Richard.. I feel happy.. and 5s for your solution.
Well.. I'm too low in knowledge, soo this was a great lesson for me, and doesn't mean I solve the problem.. more will come. I fell however sad in the end, cose in almost a year of reading and doing small programs I wasn't able to solve this one. Maybe just because I didn't have a teacher, I just do this on my own cose I like it. I wish I could give you another 5 stars , cose you deserve it.
Thanks again and my apologies for bother with these things, but for me means so much.
Cheers !!!
M@gelearn 22-Mar-21 9:09am View    
Ohh sorry McCutchan, but I still don't understand how to do this, I did cast malloc in a while loop here:

while(enteries < k && fgets(buf, sizeof buf, file2) != NULL)
{
selector[enteries] = malloc(strlen(buf) + 1);
strcpy(selector[enteries], buf);
++enteries;
}

still doesn't work.. :\
M@gelearn 22-Mar-21 6:15am View    
The code works only if I assign its size from the beginning like this for eg.

#define LINE 20

and my array will be
char *selector[LINE];
M@gelearn 22-Mar-21 5:34am View    
I will post in short time what I do really want to do with this array of pointers, and I hope someone will make me understand why I can't assign the size like I do..