September 1st, 2003, 04:03 PM
September 1st, 2003, 04:12 PM
September 1st, 2003, 04:57 PM
OK... now I'm going to embarrass all of us...
It has been pointed out to me that I've had C99 available in my IDE all along. So it all should have worked. Except for one significant problem with the code (and this was pointed out to me as well)...
I had declared my array:
which has two indexes in the first dimension:
but my code is asking for &weekDates.
Ooops... out of bounds!
At least since you all missed it too, I don't feel so bad for missing it myself :)
September 1st, 2003, 10:22 PM
>>Others have pointed out that you can't use a variable in an array declaration. However, variable length arrays were introduced in C99, and some compilers have permitted this as an extension for years. <<
To compile you must have a complier that is up to date or it would have generated errors.
MSVC.NET 2003 allows it if you use C (.c) files rather than C++ files (.cpp).
It is IMHO bad coding practice and should be avoided.
I prefer to use the WIN32 mem functions as they also tell you if they fail to free memory. A fail to free is a sign the memory has been incorrectly used.
pArray[i]=NULL;//ensure is null.
//error check all mem allocs
//use and then free memory before functin ends
The essence of Christianity is told us in the Garden of Eden history. The fruit that was forbidden was on the Tree of Knowledge. The subtext is, All the suffering you have is because you wanted to find out what was going on. You could be in the Garden of Eden if you had just kept your f***ing mouth shut and hadn't asked any questions.
September 2nd, 2003, 04:15 PM
> To compile you must have a complier that is
> up to date or it would have generated errors.
Or put that another way, for it not to compile correctly you must be using an out of date compiler.
> MSVC.NET 2003 allows it if you use C (.c) files
> rather than C++ files (.cpp).
> It is IMHO bad coding practice and should be avoided.
What's bad coding practice, variable length arrays? The alternative is to use dynamic memory allocation, which is error prone.
> I prefer to use the WIN32 mem functions as they
> also tell you if they fail to free memory. A fail to
> free is a sign the memory has been incorrectly used.
Hard to use on a non-Windows platform ;-)