{"id":5426,"date":"2024-04-21T11:56:54","date_gmt":"2024-04-21T03:56:54","guid":{"rendered":"http:\/\/www.menglanglang.cn\/?p=5426"},"modified":"2024-04-21T11:56:56","modified_gmt":"2024-04-21T03:56:56","slug":"%e5%b9%bd%e9%bb%98%ef%bc%9a%e7%a8%8b%e5%ba%8f%e5%91%98%e7%9a%84%e8%bf%9b%e5%8c%96","status":"publish","type":"post","link":"http:\/\/www.menglanglang.cn\/?p=5426","title":{"rendered":"\u5e7d\u9ed8\uff1a\u7a0b\u5e8f\u5458\u7684\u8fdb\u5316"},"content":{"rendered":"\n<p><strong>\u9ad8\u4e2d\u65f6\u671f<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">  10 PRINT \"HELLO WORLD\"\n  20 END\n<\/pre>\n\n\n\n<p><strong>\u5927\u5b66\u65b0\u751f<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">  program Hello(input, output)<br \/>    begin<br \/>      writeln(\\'Hello World\\')<br \/>    end.<br \/><\/pre>\n\n\n\n<p><br \/><strong>\u9ad8\u5e74\u7ea7\u5927\u5b66\u751f<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#include \n \nint main(void)\n{\n   printf(\"Hello, world!\\\\n\");\n   return 0;\n}\n<\/pre>\n\n\n\n<p><strong>\u804c\u4e1a\u65b0\u624b<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">  #include \n  void main(void)\n  {\n    char *message[] = {\"Hello \", \"World\"};\n    int i;\n \n    for(i = 0; i &lt; 2; ++i)\n      printf(\"%s\", message[i]);\n    printf(\"\\\\n\");\n  }\n<\/pre>\n\n\n\n<p>\u804c\u4e1a\u8001\u624b<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">  #include \n  #include \n using namespace std;\n\n  class string\n  {\n  private:\n    int size;\n    char *ptr;\n \n  string() : size(0), ptr(new char[1]) { ptr[0] = 0; }\n \n    string(const string &amp;s) : size(s.size)\n    {\n      ptr = new char[size + 1];\n      strcpy(ptr, s.ptr);\n    }\n \n    ~string()\n    {\n      delete [] ptr;\n    }\n \n    friend ostream &amp;operator &lt;&lt;(ostream &amp;, const string &amp;);\n    string &amp;operator=(const char *);\n  };\n \n  ostream &amp;operator&lt;&lt;(ostream &amp;stream, const string &amp;s)\n  {\n    return(stream &lt;&lt; s.ptr);\n  }\n \n  string &amp;string::operator=(const char *chrs)\n  {\n    if (this != &amp;chrs)\n    {\n      delete [] ptr;\n     size = strlen(chrs);\n      ptr = new char[size + 1];\n      strcpy(ptr, chrs);\n    }\n    return(*this);\n  }\n \n  int main()\n  {\n    string str;\n \n    str = \"Hello World\";\n    cout &lt;&lt; str &lt;&lt; endl;\n \n    return(0);\n  }\n<\/pre>\n\n\n\n<p><strong>\u5927\u5e08\u7ea7<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">  [\n  uuid(2573F8F4-CFEE-101A-9A9F-00AA00342820)\n  ]\n  library LHello\n  {\n      \/\/ bring in the master library\n      importlib(\"actimp.tlb\");\n      importlib(\"actexp.tlb\");\n \n      \/\/ bring in my interfaces\n      #include \"pshlo.idl\"\n \n      [\n      uuid(2573F8F5-CFEE-101A-9A9F-00AA00342820)\n      ]\n      cotype THello\n   {\n   interface IHello;\n   interface IPersistFile;\n   };\n  };\n \n  [\n  exe,\n  uuid(2573F890-CFEE-101A-9A9F-00AA00342820)\n  ]\n  module CHelloLib\n  {\n \n      \/\/ some code related header files\n      importheader();\n      importheader();\n      importheader();\n      importheader(\"pshlo.h\");\n      importheader(\"shlo.hxx\");\n      importheader(\"mycls.hxx\");\n \n      \/\/ needed typelibs\n      importlib(\"actimp.tlb\");\n      importlib(\"actexp.tlb\");\n      importlib(\"thlo.tlb\");\n \n      [\n      uuid(2573F891-CFEE-101A-9A9F-00AA00342820),\n      aggregatable\n      ]\n      coclass CHello\n   {\n   cotype THello;\n   };\n  };\n \n \n  #include \"ipfix.hxx\"\n \n  extern HANDLE hEvent;\n \n  class CHello : public CHelloBase\n  {\n  public:\n      IPFIX(CLSID_CHello);\n \n      CHello(IUnknown *pUnk);\n      ~CHello();\n \n      HRESULT  __stdcall PrintSz(LPWSTR pwszString);\n \n  private:\n      static int cObjRef;\n  };\n \n \n  #include \n  #include \n  #include \n  #include \n  #include \"thlo.h\"\n  #include \"pshlo.h\"\n  #include \"shlo.hxx\"\n  #include \"mycls.hxx\"\n \n  int CHello::cObjRef = 0;\n \n  CHello::CHello(IUnknown *pUnk) : CHelloBase(pUnk)\n  {\n      cObjRef++;\n      return;\n  }\n \n  HRESULT  __stdcall  CHello::PrintSz(LPWSTR pwszString)\n  {\n      printf(\"%ws\n\", pwszString);\n      return(ResultFromScode(S_OK));\n  }\n \n \n  CHello::~CHello(void)\n  {\n \n  \/\/ when the object count goes to zero, stop the server\n  cObjRef--;\n  if( cObjRef == 0 )\n      PulseEvent(hEvent);\n \n  return;\n  }\n \n  #include \n  #include \n  #include \"pshlo.h\"\n  #include \"shlo.hxx\"\n  #include \"mycls.hxx\"\n \n  HANDLE hEvent;\n \n   int _cdecl main(\n  int argc,\n  char * argv[]\n  ) {\n  ULONG ulRef;\n  DWORD dwRegistration;\n  CHelloCF *pCF = new CHelloCF();\n \n  hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);\n \n  \/\/ Initialize the OLE libraries\n  CoInitializeEx(NULL, COINIT_MULTITHREADED);\n \n  CoRegisterClassObject(CLSID_CHello, pCF, CLSCTX_LOCAL_SERVER,\n      REGCLS_MULTIPLEUSE, &amp;dwRegistration);\n \n  \/\/ wait on an event to stop\n  WaitForSingleObject(hEvent, INFINITE);\n \n  \/\/ revoke and release the class object\n  CoRevokeClassObject(dwRegistration);\n  ulRef = pCF-&gt;Release();\n \n  \/\/ Tell OLE we are going away.\n  CoUninitialize();\n \n  return(0); }\n \n  extern CLSID CLSID_CHello;\n  extern UUID LIBID_CHelloLib;\n \n  CLSID CLSID_CHello = { \/* 2573F891-CFEE-101A-9A9F-00AA00342820 *\/\n      0x2573F891,\n      0xCFEE,\n      0x101A,\n      { 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 }\n  };\n \n  UUID LIBID_CHelloLib = { \/* 2573F890-CFEE-101A-9A9F-00AA00342820 *\/\n      0x2573F890,\n      0xCFEE,\n      0x101A,\n      { 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 }\n  };\n \n  #include \n  #include \n  #include \n  #include \n  #include \n  #include \"pshlo.h\"\n  #include \"shlo.hxx\"\n  #include \"clsid.h\"\n \n  int _cdecl main(\n  int argc,\n  char * argv[]\n  ) {\n  HRESULT  hRslt;\n  IHello        *pHello;\n  ULONG  ulCnt;\n  IMoniker * pmk;\n  WCHAR  wcsT[_MAX_PATH];\n  WCHAR  wcsPath[2 * _MAX_PATH];\n \n  \/\/ get object path\n  wcsPath[0] = \\'\\\\0\\';\n  wcsT[0] = \\'\\\\0\\';\n  if( argc &gt; 1) {\n      mbstowcs(wcsPath, argv[1], strlen(argv[1]) + 1);\n      wcsupr(wcsPath);\n      }\n  else {\n      fprintf(stderr, \"Object path must be specified\\\\n\");\n      return(1);\n      }\n \n  \/\/ get print string\n  if(argc &gt; 2)\n      mbstowcs(wcsT, argv[2], strlen(argv[2]) + 1);\n  else\n      wcscpy(wcsT, L\"Hello World\");\n \n  printf(\"Linking to object %ws\\\\n\", wcsPath);\n  printf(\"Text String %ws\\\\n\", wcsT);\n \n  \/\/ Initialize the OLE libraries\n  hRslt = CoInitializeEx(NULL, COINIT_MULTITHREADED);\n \n  if(SUCCEEDED(hRslt)) {\n \n \n      hRslt = CreateFileMoniker(wcsPath, &amp;pmk);\n      if(SUCCEEDED(hRslt))\n   hRslt = BindMoniker(pmk, 0, IID_IHello, (void **)&amp;pHello);\n \n      if(SUCCEEDED(hRslt)) {\n \n   \/\/ print a string out\n   pHello-&gt;PrintSz(wcsT);\n \n   Sleep(2000);\n   ulCnt = pHello-&gt;Release();\n   }\n      else\n   printf(\"Failure to connect, status: %lx\", hRslt);\n \n      \/\/ Tell OLE we are going away.\n      CoUninitialize();\n      }\n \n  return(0);\n  }\n<\/pre>\n\n\n\n<p><strong>\u9ed1\u5ba2\u5b66\u5f92<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">  #!\/usr\/local\/bin\/perl\n  $msg=\"Hello, world.\\\\n\";\n  if ($#ARGV &gt;= 0) {\n    while(defined($arg=shift(@ARGV))) {\n      $outfilename = $arg;\n      open(FILE, \"&gt;\" . $outfilename) || die \"Can\\'t write $arg: $!\\\\n\";\n      print (FILE $msg);\n      close(FILE) || die \"Can\\'t close $arg: $!\\\\n\";\n    }\n  } else {\n    print ($msg);\n  }\n  1;\n<\/pre>\n\n\n\n<p><strong>\u6709\u7ecf\u9a8c\u7684\u9ed1\u5ba2<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">  #include \n  #define S \"Hello, World\\\\n\"\n  main(){exit(printf(S) == strlen(S) ? 0 : 1);}\n<\/pre>\n\n\n\n<p><strong>\u8001\u7ec3\u7684\u9ed1\u5ba2<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">  % cc -o a.out ~\/src\/misc\/hw\/hw.c\n  % a.out\n<\/pre>\n\n\n\n<p><strong>\u8d85\u7ea7\u9ed1\u5ba2<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">  % echo \"Hello, world.\"\n<\/pre>\n\n\n\n<p><strong>\u4e00\u7ebf\u7ecf\u7406<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">  10 PRINT \"HELLO WORLD\"\n  20 END\n<\/pre>\n\n\n\n<p><strong>\u4e2d\u5c42\u7ecf\u7406<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">  mail -s \"Hello, world.\" bob@b12\n  Bob, could you please write me a program that prints \"Hello, world.\"?\n  I need it by tomorrow.\n  ^D\n<\/pre>\n\n\n\n<p><strong>\u9ad8\u7ea7\u7ecf\u7406<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">  % zmail jim\n  I need a \"Hello, world.\" program by this afternoon.\n<\/pre>\n\n\n\n<p><strong>\u9996\u5e2d\u6267\u884c\u5b98<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">  % letter\n  letter: Command not found.\n  % mail\n  To: ^X ^F ^C\n  % help mail\n  help: Command not found.\n  % damn!\n  !: Event unrecognized\n  % logout<\/pre>\n\n\n\n<p>\u539f\u6587\u94fe\u63a5\uff1a<a href=\"https:\/\/coolshell.cn\/articles\/172.html\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/coolshell.cn\/articles\/172.html<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/coolshell.cn\/haoel\" target=\"_blank\" rel=\"noreferrer noopener\">\u5de6\u8033\u6735\u8017\u5b50<\/a>\u5927\u795e\u5df2\u79bb\u53bb\u5feb\u4e00\u5e74\u4e86\uff0c\u8fd9\u4e24\u5929\u65e0\u610f\u95f4\u53c8\u7ffb\u5230\u4e86\u4ed6\u7684 BLOG\uff0c\u7ffb\u770b\u4ed6\u4e4b\u524d\u7684\u6587\u7ae0\u5e76\u628a\u90e8\u5206\u8f6c\u8f7d\u8fc7\u6765\uff0c\u52c9\u52b1\u81ea\u5df1\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9ad8\u4e2d\u65f6\u671f 10 PRINT &#8220;HELLO WORLD&#8221; 20 END \u5927\u5b66\u65b0\u751f program Hello(i [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[316],"tags":[381,259],"class_list":["post-5426","post","type-post","status-publish","format-standard","hentry","category-it-fun","tag-381","tag-259"],"_links":{"self":[{"href":"http:\/\/www.menglanglang.cn\/index.php?rest_route=\/wp\/v2\/posts\/5426","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.menglanglang.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.menglanglang.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.menglanglang.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.menglanglang.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5426"}],"version-history":[{"count":1,"href":"http:\/\/www.menglanglang.cn\/index.php?rest_route=\/wp\/v2\/posts\/5426\/revisions"}],"predecessor-version":[{"id":5427,"href":"http:\/\/www.menglanglang.cn\/index.php?rest_route=\/wp\/v2\/posts\/5426\/revisions\/5427"}],"wp:attachment":[{"href":"http:\/\/www.menglanglang.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5426"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.menglanglang.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5426"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.menglanglang.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5426"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}