Hi!
I'm making a graph generator.
Most is done but the only problem is that when i'm doing the 2nd or 3rd graph in the same session, the graph collapses . and after the end of execution of the program, i get "Null pointer assignment"
I tried debugging but i have only found out that the functions calculating the functional value start giving zero at a certain point.
That point is different for different inputs.
If i close the program after the first graph, the error is not returned and after starting it again it works again for atleast the first time.
If it helps, I am posting the two functions responsible for function solving.
Screenshots below code
int eqn::valuefinder(double v,int two)
{
if(two)
strcpy(eqan2,seceqan);
if(two==0)
strcpy(eqan2,eqan);
char xchar[10];
sprintf ( xchar, "%.3f", v );
for(int i=0;i<strlen(eqan2); i++)
{
if (eqan2[i]=='x' || eqan2[i]=='X')
{
replacer(eqan2,xchar,i,i);
}
}
int val=manager_eqn(eqan2);
return(val);
}
void eqn::replacer(char* a,char* b,int m,int n) //inserts b inside a from index m to n
{
int j=0,k,i,l,size=(strlen(a)-n);
char *sub=new char[size];
for(i=n+1; a[i]!='\0' ;i++)
{
sub[j]=a[i];
j++;
}
sub[j]='\0';
for (i=m,j=0; b[j]!='\0' ; i++,j++,k=i)
a[i]=b[j];
for (i=k,j=0; sub[j]!='\0'; i++,j++)
a[i]=sub[j];
a[i]='\0';
}