my code is in c and will appreciate the help. so far I am trying to store character arrays(strings) to the list with out links and now I am trying to create nodes and link them together. I am not sure what im doing wrong since the compiler does not return any error. probably its logical, help?
please ignore the unused variables :)
#include<stdio.h> #include<stdlib.h> #include<conio.h> #include<string.h> typedef char string20[21]; typedef string20 words[4]; struct questag{ words mystery; int wcnt; string20 cat; }; struct quesnodetag{ struct questag data; struct quesnodetag *pnext; }; struct quesnodetag * createnewnode(char cat[],char word[],int cnt){ struct quesnodetag *ptemp; ptemp=malloc(sizeof(struct quesnodetag)); strcpy(ptemp->data.mystery[0],word); strcpy(ptemp->data.cat,cat); ptemp->data.wcnt=cnt; ptemp->pnext=NULL; return ptemp; } void insertnodeatend(struct quesnodetag *pt,struct quesnodetag *new){ struct quesnodetag *temp; if(pt==NULL ) pt=new; else{ temp=pt; while(temp->pnext!=NULL) temp=temp->pnext ; temp->pnext=new ; } } void inserteasy(struct quesnodetag *easyp,char cat[],char easy[],int cnt){ struct quesnodetag *new; new=createnewnode(cat,easy,cnt); insertnodeatend(easyp,new); } void insertmed(struct quesnodetag *medp,char cat[],char med[],int cnt){ struct quesnodetag *new; new=createnewnode(cat,med,cnt); insertnodeatend(medp,new); } void insertdiff(struct quesnodetag *diffp,char cat[],char diff[],int cnt){ struct quesnodetag *new; new=createnewnode(cat,diff,cnt); insertnodeatend(diffp,new); } void insertbonus(struct quesnodetag *bonusp,char cat[],char bonus[],int cnt){ struct quesnodetag *new; new=createnewnode(cat,bonus,cnt); insertnodeatend(bonusp,new); } int main(){ int choice_1,choice_2,turn,quit=0,round=1,category=0,k; int i,j,past=0,indicator1=0,indicator2=0,secpast=50,set=0; int secpast2=50,past2=0,cat_cnt=5; char player_1[51],player_2[51],password[21],*pt,quit_char[1],test[5]; struct quesnodetag *easy,*med,*diff,*bonus; inserteasy(easy,"Food and Drink","pizza",1); inserteasy(easy,"Occupation","barber",1); inserteasy(easy,"Landmark","trinoma",1); inserteasy(easy,"Persons and People","Lasallians",1); inserteasy(easy,"things","fork",1); insertmed(med,"Food and Drink","hash brown",2); insertmed(med,"Occupation","bicycle repairer",2); insertmed(med,"Landmark","star city",2); insertmed(med,"Persons and People","adrian bachini",2); insertmed(med,"things","laptop sleeve",2); insertdiff(diff,"Food and Drink","java chip frappuccino",3); insertdiff(diff,"Occupation","computer systems analyst",3); insertdiff(diff,"Landmark","rizal memorial stadium",3); insertdiff(diff,"Persons and People","ludwig van beethoven",3); insertdiff(diff,"things","portable usb charger",3); insertbonus(bonus,"Food and Drink","fried siomai",2); insertbonus(bonus,"Occupation","software engineer",2); insertbonus(bonus,"Landmark","chocolate hills",2); insertbonus(bonus,"Persons and People","lebron james",2); insertbonus(bonus,"things","friction pen",2); return 0; }