- 1 Getting started
- 2 Compile
- 3 Customize
- 4 Optimize
- 5 Debug
- 6 Non-standard extensions
- 7 System Routines
- 附录 A
- 附录 B
- 附录 E
- 附录 I
文章来源于网络收集而来,版权归原创者所有,如有侵权请及时联系!
1.1 Hello, world!
This is a sample program that displays “Hello, world!”:
---- hello.cob ------------------------- * Sample COBOL program IDENTIFICATION DIVISION. PROGRAM-ID. hello. PROCEDURE DIVISION. DISPLAY "Hello, world!". STOP RUN. ----------------------------------------
The compiler, cobc
, is executed as follows:
$ cobc -x hello.cob $ ./hello Hello, world!
The executable file name (hello in this case) is determined by removing the extension from the source file name.
You can specify the executable file name by specifying the compiler option -o as follows:
$ cobc -x -o hello-world hello.cob $ ./hello-world Hello, world!
The program can be written in a more modern style, with free format code, inline comments, the GOBACK
verb and an optional END-DISPLAY
terminator:
---- hellonew.cob ---------------- *> Sample GnuCOBOL program identification division. program-id. hellonew. procedure division. display "Hello, new world!" end-display goback. ----------------------------------
To compile free-format code, you must use the compiler option -free.
$ cobc -x -free hellonew.cob $ ./hellonew Hello, new world!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论