ok so I have a few problems with my code, first off the program i am trying to make uses a database, the user inputs a date and my program will turn it into a code that it will store in a txt file and the program will read it every night at mid night and if it has a code correspondes with the date it will show on the screen how many there are. but my problem right now is that i cant change the date to code.
this is what i was trying to do but it crashes. this test does not include the whole date i was only testing with february, (at one point i think i try to change a char variable into an int variable, i dont no if this is legal or not so feel free to comment about it.) i have included an attachment if you wish to run it in your compiler.
#include <conio.h>
#include <stdio.h>
int main(int arge, char *argv[])
{
FILE *pfile;
int month;
char sced[21];
float date[32];
char answer = 'y';
char num1;
char february;
pfile = fopen("database2.txt", "w");
if (pfile != NULL)
{
while (answer == 'y')
{
printf("write the month: ");
if (month == february);
{
february = 01;
}
scanf("%s", &month);
printf("what is happening:");
scanf("%s", &sced);
printf("loading");
fprintf(pfile,"%s", &sced); /* crashes here*/
fprintf(pfile,"%s\n", &month);
printf("do you wish to put in any more dates [y/n] \n");
answer = getch();
}
fclose(pfile);
}
else
{
printf("could not open the file.\n");
}
getch();
}



LinkBack URL
About LinkBacks



, but when I open the program this is what is does :