while installing the dev c set up i got a message that it was not able to include some lib and some include files and that this can create problem during compilation. it asked whether i wanted to continue installing. i clicked yes.
now when i run a simple program which uses only gets and puts, it doesnt input the string and after some debugging, i found that it reports access violation compilation error.
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
int flag,n;
struct node
{
char *word;
struct node *left;
struct node *right;
};
struct node *root;
char *w,*line;
struct node *addtree(struct node *p,char *s)
{
if(p==NULL)
{
p->word=s;
p->left=NULL;
p->right=NULL;
}
else if(strcmp((p->word),s)>0)
p->left=addtree(p->left,s);
else
p->right=addtree(p->right,s);
return p;
}
int comp(char *u)
{
int i=0;
// flag=1;
while(i<n)
{
if(u[i]!=line[i])
{
// flag=0;
return 0;
}
i++;
}
if(u[n]!=line[n])
return 1;
else
return 0;
}
void traverse2(struct node *t)
{
if(strlen(t->word)>n)
traverse2(t->left);
if(comp(t->word))
puts(t->word);
traverse2(t->right);
}
void traverse1(struct node *p)
{
if(p!=NULL)
traverse1(p->left);
line=p->word;
traverse2(root);
traverse1(p->right);
}
int main()
{
root=NULL;
//w=NULL;
printf("enter words");
fflush(stdin);
gets(w);
// printf("\ngets(w)=:%d",gets(w));
//while(gets(w)!=NULL)
//root=addtree(root,w);
printf("\nenter n");
scanf("%d",&n);
//traverse1(root);
printf("*w=\n");
puts(w);
getch();
return 0;
}
here is my code which i have reduced by including the function calls in comments