-
Notifications
You must be signed in to change notification settings - Fork 0
/
fntest.c
48 lines (37 loc) · 857 Bytes
/
fntest.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "fn.h"
/* cc -o fntest fntest.c libfn.a -ll -ly -lm */
int main()
{
FN *f;
float d;
double *x, *y, z;
char s[2];
char function[512];
printf("Please give me a functional form using variables x and y.\n");
scanf("%s", function);
printf("'%s'\n", function);
strcat(function, "\n");
f=fnopen(function);
x = fnmemory(f, 'x');
y = fnmemory(f, 'y');
printf("Please give me values for x and y :\n x = ");
scanf("%f", &d);
*x = d;
printf("\n y = ");
scanf("%f", &d);
*y = d;
printf("(x,y)=(%lf,%lf)\n", *x, *y);
printf("result = %lf\n", fnread(f));
while (1)
{
z = fnread(f);
printf("I now set x with the f(x,y): %lf\n", z);
*x = z;
printf("Insert a character and press return... ");
scanf("%s", s);
}
}
int yywrap() { return 1; }