Hi,
Im having a really simple problem.
I have an if statement to check if an input from a user is empty or not, if it is then the program needs to take one course of action. if it isnt then it uses it.
Its a prompt for a filename to save some variables to, reading into a character array[20] called filename, I will be changing from gets to something else shortly but I want to get the if statement working first.
now before I had the option to enter a filename it automatically it would save to default.dat with that exact same line. Now it doesnt seem to register that filename is null when I dont input anything.Code:printf("Enter filename"); gets(filename); if(filename == NULL) { savefile = fopen("default.dat","w"); } else { savefile = fopen(filename, "w"); }
Is this because its an array so I cant use a simple if == Null statement?
or, because its picking up some random place in memory its never actually empty?
Thanks for any pointers.