okay ive gotten some errors worked out so far but my programs crashes but no errors in the compiler.this is my entire program.nneeds to read from a file though.please tell me what my errors can be
Code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
FILE*in;
typedef struct node{
char word[20];
int count;
struct node *next;
}Node,*Nodeptr;
Nodeptr addinplace(Nodeptr ,char[] );
Nodeptr makenode(char[] );
int main(){
in=fopen("shims.txt","r");
if(in==NULL){
printf("Filenot found!! \n");
system("pause");
exit(1);
}
char wod[20];
Nodeptr start=NULL;
fscanf(in,"%s",&wod);
while(strcmp(wod,'\0')!=0){
start=addinplace(start,wod);
fscanf(in,"%s",&wod);
}
fclose(in);
system("pause");
return 0;
}
//making a node to hold the word
Nodeptr makenode(char string[]){
Nodeptr str=(Nodeptr)malloc(sizeof(Node));
strcpy(str->word,string);
str->next=NULL;
return str;
}
//adds words inorder into th list
Nodeptr addinplace(Nodeptr top,char string[]){
Nodeptr str,curr,prev,makenode(char[]);
str=makenode(string);
prev=NULL;
curr=top;
while(curr!=NULL && strcmp(curr->word,string)<0){
prev=curr;
curr=curr->next;
}
if(prev==NULL){
str->next=top;
return str;
}
str->next=curr;
prev->next=str;
return top;
}