Hi at the moment my program takes in 6 strings and saves them to a text file.
Each time it saves to text file, the line changes to something like this
a = 1, b = 2, c = 3, Xo = 4, Yo = 5, Zo = 6,
How can i change the code so instead of deleting the last line that is there it adds a line ABOVE it so you get
a = 7, b = 8, c = 9, Xo = 10, Yo = 11, Zo = 12,
a = 1, b = 2, c = 3, Xo = 4, Yo = 5, Zo = 6,
and how can i make it only ever have 6 lines in the file. (the file is a recent data file, so instead of a user having to type data in everytime, the user can see data used before - the last 6 times).
And last question - to recall this data, what is the best way to do it - can i get the computer to notice the commas, and store the number just before it into a float?
thanks:
Code:
char *options[100], *a[100], *b[100], *c[100], *Xo[100], *Yo[100], *Zo[100];
FILE *recentdata;
printf("Please input a, b and c, or type 'recent' to see a list of recently used data.\n");
scanf("%99s", options);
if(strcmpi(options,"recent") == 0)//compare options to "recent" NOT case sensitive.
{
//write a function for recent
printf("finding recent files");
}
else
{
strcpy(a,options);
scanf("%99s", b);
scanf("%99s", c);
printf ("%s %s %s\n\n", a, b, c);
printf("Please input Xo, Yo and Zo\n");
scanf("%99s", Xo);
scanf("%99s", Yo);
scanf("%99s", Zo);
printf ("%s %s %s\n\n", Xo, Yo, Zo);
printf("Executing Improved Euler...");
}
recentdata = fopen("recentdata.txt", "w");
fprintf(recentdata, "a = %s, b = %s, c = %s, Xo = %s, Yo = %s, Zo = %s,\n", a, b, c, Xo, Yo, Zo);
fclose;
return 0;