#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
int stringLength(char inputString[])
{
int length = 0;
for (int i = 0; inputString!= '\0'; i++)
length++;
return length;
}
void main (void)
{
int count=0; int n=0; int i,j;
FILE *p=fopen("xx.txt","r");
if(p==NULL)
{
printf("wrong");
exit(1);
}
//-----------read from file to string array equation----------------------
char equations[50][150];
char *fileline=(char *)malloc(100*sizeof(char));
int equations_count=0;
while(fscanf(p,"%s",fileline)!=EOF)
{
int len;
len= stringLength(fileline);
for(j=0;j<=len;j++)
equations[equations_count][j]=fileline[j];
equations_count++;
puts(fileline);
}
printf("\n THE NO OF EQN =%d\n",equations_count);
fclose(p);
//----------------------------------------------------------------
//----------------------------------------------------------------
int b=equations_count;
float **coeff=(float**)malloc(b*sizeof(float*));
for(i=0;i<b;i++)
coeff=(float*)malloc(b*sizeof(float));
for(i=0;i<b;i++)
for(j=0;j<b;j++)
{
coeff[j]=0;
if(j%b==0)
printf("\n");
printf("%f \t",coeff[j]);
}
//-------------coeff initialization matrix--------------------------
float *result=(float*)malloc(b*sizeof(float));
for(i=0;i<b;i++)
result=0;
//-------------result matrix----------------------------------------
char **v=(char**)malloc(b*sizeof(char*));
for(i=0;i<b;i++)
v=(char*)malloc(100*sizeof(char));
//-------------var_names(array of string)---------------------------
char stock[100];int k=0;int t=0;
for(i=0;i<b;i++)
for(j=0;j<(strlen(equations)+1);j++)
{
if(isalpha(equations[j])!=0)
{
stock[k]=equations[j];
k++;
}
else
if(strlen(stock)!=0)
{
stock[k]=NULL;
char *p;
for(i=0;i<b;i++)
{
p=strstr(&v[0],stock);
if(p!=NULL)
{
t++;
}
}
if(t==0)
{
strcpy(v[t],stock);
t++;
}
k=0;
stock[0]='\0';
}
}
printf("%s",v[0]); المشكله انو لما بيجي يطبع بيطبع رابيش
قبل مانحط فيه النال stock مش المفرض يطبع اول حاجه كانت في
}