Timeline for PSET4 - Need help with Recover problem
Current License: CC BY-SA 4.0
5 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 12, 2020 at 21:21 | comment | added | Cliff B | (...continued) Or, if it is immediately going to get a valid address assigned to it, only then is it acceptable to not initialize. (It's still a best practice to do so anyways.) You should get in the habit of always initializing variables when created. If you're referring to something else, can you be more specific? | |
Jul 12, 2020 at 21:07 | comment | added | Cliff B | Not precisely sure what you mean by "the filename" in this context, but I'll try to cover the bases. A string, char array, of FILE * are all pointers. The rule about pointers is that when they are created, the value in the pointer is NOT initialized. Pointers will contain whatever garbage data exists in the physical memory assigned to that variable. So, best practice is to ALWAYS initialize a pointer variable when it is created. That could mean setting it to NULL, allocating memory with a call to malloc or calloc, or inserting a valid address into that pointer, (continues....) | |
Jul 12, 2020 at 12:40 | comment | added | jakec1234 | hey, can i ask, why do you have to initialise the filename? | |
Jul 12, 2020 at 8:46 | vote | accept | Neus F. | ||
Jul 12, 2020 at 8:28 | history | answered | Cliff B | CC BY-SA 4.0 |