Quote:
Originally posted by monica_green_22@14 September 2003 - 14:34
C++ is a good language to learn as a first language, but learning assembly is also a good way to start. The learning curve is very steep, but the understanding of the architecture of modern computers that you will learn with assembly is worth it. Yes learning asm on segmented architectures is hard, but its also very interesting.
The code is faster, smaller, and very easy to debug with modern tools.
As for your code:
There is no "using" keyword in C, likewise, there are no namespaces, so your C program is incorrect. C has no concept of namespaces.
Your C++ example is very outdated (as of 1998), when the standard was published, code such as yours is no longer compliant. The header for the standard iosteam library is now <iostream> (no .h, likewise with any C++ headers).
Also, the "\n" at the end of your string is redundant, as '\n' is appended by the std::endl object, which also flushes the stream.
Portability is a key factor in deciding language, but how often have you had your cod ecompiled on a different architecture? asm remains a good choice to learn, especially seeing as the x86 architecture is not going anywhere. Itanium is still off in the distant future, and AMD Opteron/Athlon64 have full 32-bit compatibility.
Monica
Sorry, but I am not a C programmer, C++ ;). But I often get confused between the two (switching back and forth) but I found using VS .NET I find myself having to use ".h" but with ANSI C++ I do exactly as you say and use just plain "<iostream>", I find that the "\n" escape character's fine with me though. :unsure: