XSLT存档  

不及格的程序员-八神

 查看分类:  ASP.NET XML/XSLT JavaScripT   我的MSN空间Blog
随笔 - 878,  文章 - 0,  评论 - 1190,  阅读 - 34万
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
复制代码
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()
复制代码

 

posted on   不及格的程序员-八神  阅读(16)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
历史上的今天:
2019-08-28 SOAP MIME Attachment
2019-08-28 Calling WCF Services using jQuery
点击右上角即可分享
微信分享提示