#include "clio.h" #include int write_to_file(char *filename) { FILE *fp; fp = fopen(filename, "w"); fprintf(fp, "%s\n", getContinuousName(getX)); fprintf(fp, "%s\n", getContinuousName(getY)); fprintf(fp, "%s\n", getContinuousName(getZ)); fprintf(fp, "%s\n", getContinuousName(getW)); fprintf(fp, "%s\n", getContinuousName(getH)); fprintf(fp, "%s\n", getContinuousName(getD)); fprintf(fp, "%s\n", getContinuousName(getShade)); fprintf(fp, "%s\n", getDiscreteName(getColor)); fprintf(fp, "%s\n", getDiscreteName(getShape)); fclose(fp); return 0; } int get_from_file(char *filename) { char x[20], y[20], z[20], w[20], h[20], d[20], s[20], c[20], shape[20]; FILE *fp; if(NULL == (fp= fopen(filename, "r"))){ error_load_save(); fprintf(stderr, "FILE NOT FOUND %s*\n", filename); } else{ fscanf(fp,"%s",x); getX= getContinuousFunction(x); fprintf(stderr, "setting x to %s\n", getContinuousName(getX)); fscanf(fp,"%s",y); getY= getContinuousFunction(y); fprintf(stderr, "setting y to %s\n", getContinuousName(getY)); fscanf(fp,"%s",z); getZ= getContinuousFunction(z); fprintf(stderr, "setting z to %s\n", getContinuousName(getZ)); fscanf(fp,"%s",w); getW= getContinuousFunction(w); fprintf(stderr, "setting w to %s\n", getContinuousName(getW)); fscanf(fp,"%s",h); getH= getContinuousFunction(h); fprintf(stderr, "setting h to %s\n", getContinuousName(getH)); fscanf(fp,"%s",d); getD= getContinuousFunction(d); fprintf(stderr, "setting d to %s\n", getContinuousName(getD)); fscanf(fp,"%s",s); getShade= getContinuousFunction(s); fprintf(stderr, "setting s to %s\n", getContinuousName(getShade)); fscanf(fp,"%s",c); getColor= getDiscreteFunction(c); fprintf(stderr, "setting c to %s\n", getDiscreteName(getColor)); fscanf(fp,"%s",shape); getShape= getDiscreteFunction(shape); fprintf(stderr, "setting shape to %s\n", getDiscreteName(getShape)); fclose(fp); } }