Beginners Project: Hello World (using C): Difference between revisions

From Try-AS/400
Jump to navigation Jump to search
(Created page with "Since Heiko is fairly familiar with C, here's his approach for a simple "Hello World!" in C. === Create a library for source and program === * <code>CRTLIB</co...")
 
No edit summary
Line 1: Line 1:
Since [[User:Heiko|Heiko]] is fairly familiar with C, here's his approach for a simple "Hello World!" in C.
Since [[User:Heiko|Heiko]] is fairly familiar with C, here's his approach for a simple "Hello World!" in C.


=== Create a library for source and program ===
== Create a library for source and program ==
* <code>CRTLIB</code> + <code>F4</code>
* <code>CRTLIB</code> + <code>F4</code>
** Enter this:<br/>[[Image:HelloWorldC01.png|400px]]
** Enter this:<br/>[[Image:HelloWorldC01.png|400px]]
== Create a Source Physical File ==
* <code>CRTSRCPF</code> + <code>F4</code> named <tt>SNDBX</tt>
== Create the C source code ==
* To create the source code as member of the SPF: <code>WRKMBRPDM</code> + <code>F6</code>, enter name (<tt>hello_c</tt>) and type (<tt>C</tt>)
* enter this in SEU:
  Spalten . . . :    1 100                                    Editieren                                                SNDBX/SNDBX
  SEU==>                                                                                                                    HELLO_C
  FMT **  ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0                     
        ***************** Datenanfang ******************************************************************************************* 
0001.00 #include <stdio.h>                                                                                      191007           
0002.00 int main(void)                                                                                          191007           
0003.00 {                                                                                                        191007           
0004.00  printf("Hello World!\n");                                                                              191007           
0005.00  return 0;                                                                                              191007           
0006.00 }                                                                                                        191007           
        ******************Datenende ********************************************************************************************* 
* close and save with <code>F3</code>
* enter <code>14</code> to compile
* check with <code>DSPMSG</code> the outcome
== Run the progra ==
[[Category:Basic Knowledge]]

Revision as of 21:31, 7 October 2019

Since Heiko is fairly familiar with C, here's his approach for a simple "Hello World!" in C.

Create a library for source and program

  • CRTLIB + F4
    • Enter this:
      HelloWorldC01.png

Create a Source Physical File

  • CRTSRCPF + F4 named SNDBX

Create the C source code

  • To create the source code as member of the SPF: WRKMBRPDM + F6, enter name (hello_c) and type (C)
  • enter this in SEU:
 Spalten . . . :    1 100                                     Editieren                                                 SNDBX/SNDBX
 SEU==>                                                                                                                     HELLO_C
 FMT **  ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0                       
        ***************** Datenanfang *******************************************************************************************  
0001.00 #include <stdio.h>                                                                                       191007            
0002.00 int main(void)                                                                                           191007            
0003.00 {                                                                                                        191007            
0004.00   printf("Hello World!\n");                                                                              191007            
0005.00   return 0;                                                                                              191007            
0006.00 }                                                                                                        191007            
        ******************Datenende *********************************************************************************************  
  • close and save with F3
  • enter 14 to compile
  • check with DSPMSG the outcome

Run the progra