Code:
FILE *fp; //This is declared at the very top of program. outside of any functions
int main(int argc, char *argv[])
{
int x;
if(argc == 1) //if only 1 entry in array then go to menu
{
showMenu(0);
}
else //otherwise a filename or argument was passed in, so try to open
{
fn[0] = argv[1];
confirmFile(fn); //pass filename to function confirmFile
}
return 0;
}
int confirmFile(char *fn[])
{
fp=fopen(fn[0],"w"); //open File, point fp to the filename
showMenu(1); //run menu function, passing 1 to signify that a file was opened on load
}
//I wont show the menu as its by the by, the below is the closeFile function which follows
// on to directly close the file when called.
int closeFile()
{
//printf("%s\n", fn[0]);
//printf("%d\n", *fn[0]);
//printf("%f\n",fp);
fclose(fp);
return(0);
}
I think that's the important parts covered, am I making a simple error here?