View Full Version : C vs. C++ vs. C# Lucky 06-22-2012, 09:48 PM Hi. I am a computer scientist. This is a comparison of memory usage for a simple hello world application between C, C++, and C#. Compiled VS2010 32-bit x86 Release. // C# // 1,968k using System; namespace hellonet { class Program { static void Main(string[] args) { System.Console.Write("hello world"); System.Console.ReadKey(); } } } // C++ // 640k #include <iostream> int main(int argc, char* argv[]) { std::cout << "hello world"; std::cin.get(); return 0; } // C // 484k #include <stdio.h> int main(int argc, char* argv[]) { printf("hello world"); getchar(); return 0; } As you can see, C# uses 5x as much memory as C and 3x more than C++ just for a simple hello world application. And M$ is writing Windows.Next kernel in this managed language. Rogean you can thank me for the adsense money from the future googlers that will find this site (as applies to all of my insights made here).
You should use neither. You should use #include <iostream> ... int main() { ... std::cin.ignore(); //why read something if you need to ignore it? :) }' Here's the documentation
Example: #include <iostream> #include <conio.h> int main() { std::cout << "Press any key to continue . . ." << std::endl; _getch(); // wait for keypress } _getch() is C++ equivalent to C getch()
南来地,北往的,上班的,下岗的,走过路过不要错过!
======================个性签名=====================
之前认为Apple 的iOS 设计的要比 Android 稳定,我错了吗?
下载的许多客户端程序/游戏程序,经常会Crash,是程序写的不好(内存泄漏?刚启动也会吗?)还是iOS本身的不稳定!!!
如果在Android手机中可以简单联接到ddms,就可以查看系统log,很容易看到程序为什么出错,在iPhone中如何得知呢?试试Organizer吧,分析一下Device logs,也许有用.