We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
did you get any resolution / suggestions on this, i have a problem with the same two test cases, says i'm segfaulting on 16 & 17 but gcc version 6.3.1 20161221 (Red Hat 6.3.1-1) (GCC) with options -g & -Wall disagrees. my code:
include
include
include
include
include
include
include
struct node{
char *word;
int count;
struct node *next;
};
Hash Tables: Ransom Note
You are viewing a single comment's thread. Return to all comments →
did you get any resolution / suggestions on this, i have a problem with the same two test cases, says i'm segfaulting on 16 & 17 but gcc version 6.3.1 20161221 (Red Hat 6.3.1-1) (GCC) with options -g & -Wall disagrees. my code:
include
include
include
include
include
include
include
struct node{ char *word; int count; struct node *next; };
void mainlist(char *word, struct node **list){ struct node *tmp = *list; struct node *prev = 0; if(!tmp){ (*list) = calloc(1,sizeof(*list)); (*list)->word = word; (*list)->count = 1; (*list)->next = 0; return; } while(tmp){ if(strcmp(tmp->word,word)==0){ (tmp->count)++; return; } prev = tmp; tmp = tmp->next; } prev->next = calloc(1, sizeof(prev->next)); prev->next->word = word; prev->next->count = 1; prev->next->next = 0; return; }
struct node *inlist(char *word, struct node **list){ struct node *n = *list; while(n){
if(strcmp(n->word, word)==0){ return n; } n = n->next; } return 0; }
int main(){ int m; int n; scanf("%d %d",&m,&n);
}