>>What do you mean with out-dated? That is correct both syntatically and semantically though not usual style.
I'm not saying it's incorrect. It's out-dated trick (because)that it's nothing unusual for most C programmers.
>>What do you mean with out-dated? That is correct both syntatically and semantically though not usual style.
I'm not saying it's incorrect. It's out-dated trick (because)that it's nothing unusual for most C programmers.
Last edited by Bayint Naung; 07-15-2010 at 08:04 AM.
KIBO: If you would've read couple posts further you would've found out that that was already explained.
Anyone who works professionally knows why this is important to understand. When you get a career in programming you'll find ancient code written like this perhaps for an older compiler. The world is filled with C code. In our case at work, we upgraded compilers and the old code was still there. What you do need to know are these little things so you can upgrade your code as needed to be current with the standard. For example, I'm sure you ran across "iostream.h" in C++ whereas the new standard header is iostream. Not to mention, upgrading from a C to C++ compiler means you need to change an old header "time.h" by removing the .h and adding a 'c' to the begnning of the file. Knowing these things help you become a top-notch C/C++ developer. So yes, you do need to understand it enough to read it and know the differences.
That raises an interesting question though. Consider your original question: "What's wrong with this code while compiling on a C89 compiler?"Originally Posted by dxfoo
I confess that my immediate reaction is to look for what might cause a compile error with respect to C89. But in truth, what is wrong is more than that. For example, the use of the identifier-list form for the parameter declarations of a function definition, although legal even in C99, is wrong, on the basis of readability and the fact that the arguments will not be converted to the declared parameter types. Likewise, the expression 3[array], although again perfectly legal even in C99, is also wrong, on the basis of readability. The use of implicit-int is perhaps more debatable, but again it could be regarded as wrong, on the basis that forward compatibility with C99 is easy to achieve, with increased readability by being explicit.
That is not actually an upgrade: they are different programming languages, despite what they have in commonOriginally Posted by dxfoo
And also change time to std::time, unless an appropriate using declaration or using directive is in scope.Originally Posted by dxfoo
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)