the following code snippet is from a function I wish to add to an existing program. it looks good to me , the compiler is happy with it, but when the program encounters it, the program stops, (or disappears off into an infinite loop somewhere) and I get a dialog box telling me the program has "Stopped working".
The puts() statements before and after this snippet show me that it is this bit of code that is killing the program.
the file it is trying to access does exits, and is closed.
Any ideas?
void fill_array(void)
{
struct data_cell save_1 , save_2 , save_3 ;
int array_no , a , b , c ;
int dimensions[3];
char new_cell_data[20];
char path = "C:\\Users\\dave\\Documents\\data.txt";
FILE *fp;
puts("Got here_1");
if ((fp = fopen(path,"w")) == NULL)
{
printf("cannot open file");
exit(1);
}
puts("Got here_2");
printf("Enter the target array, (range 1 - 3 \t");
scanf("%d", &array_no);
...... more code......
fclose(fp);
}