Did you know that C (and, consequently, C++) allows you to escape newlines in any context? For example, the following is a perfectly valid piece of code:
const char str[] = "foo/bar";int long_var/_name = 0;int funct/ion(unsi/gned int i) { // works even with / one-line comments in C99/C++ whi/le(i) { i -/= 1; }}
EDIT: Argh, the forum software seems to eat backslashes like there's no tomorrow :( Just pretend that the forward slashes are actually backslashes.
Quote:Original post by Polymorphic OOP Sure it does! 'dab' is a multicharacter literal, which has type int. Completely standard.
Every day, a new reason to despise C and its various bastard offspring.
You blaspheme! =b I've always liked the freedom of C++. Granted, it's not perfect (far from it) but at least it allows you to apply some imagination unlike BASIC (and all of it's bastard offspring =b).
I have yet to find a language that treats the programmer with as much respect as C/C++ do. D looks pretty promising, however; I just wish the tool support was improved.
I'm largely put off by languages with political bents. I'm not interested in converting the world to a specific platform, just in writing great software that is clear, expressive, and easy to understand. Users shouldn't be able to tell that I wrote it in a non-C language (witness Azureus and its reports of grinding computers to a halt - yay garbage collection and massive frameworks!!!) And it should have good IDE support for things that we take for granted, such as Intellisense and whatnot.
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis
Logically that makes sense, but it's still strange because they obviously had to explicity define the '[]' operator for non-array types that take an array or pointer type as a parameter. And even if it is logical, emotion is telling me that it's weird. :p
I'm working off my brain and not a compiler here, but first[array] would not contain the type information that array[first] would, so your compiler should at least warn you when you try to use this syntax. Needless to say, if array was of a type different to int, the code will probably behave strangely on allocation.
Of course, I'm assuming that the compiler implicitly casts from an int to a pointer [void*] in the case of array, and that it implicitly casts from a pointer to an int in the case of first - which I wouldn't have expected it to do without complaining.