Hi Could somebody help me with my homework.
Use functions and structures.
Strings in input file 'AND', 'OR' ja 'NOT' must be replaced with symbols '&', 'v' ja '-' and saved into output file.
Example of input:
C = A AND B
D = A OR C
E = NOT (C OR D)
Output:
C = A & B
D = A v C
E = -(C v D)
#include <stdio.h>
#include <string.h>
#define max 100
int main()
{
static const char *a = "file.txt";
fi = fopen( "*a", "r");
fo = fopen("out.txt","w");
char delims[] = " ";
char *result = NULL;
strtok( "*a", delims );
while(*a!='\0')
{
if(*a == 'AND')
*a='&';
else if(*a=='OR')
*a='V';
else if(*a=='NOT')
*a='-';
a++;
}
while( result != NULL ) {
printf( "result is \%s\\n", result );
result = strtok( NULL, delims );
}
fprintf(fo,"Input: %s \n",mass);
fclose(fi);
replace(mass);
printf("%s \n",mass);
fprintf(fo,"Output: %s \n",array);
fclose(fo);
fclose(fi);
getch();
return 0;
}