Calendar - for "REAL" programmers: Difference between revisions

Content added Content deleted
(→‎{{header|C}}: More notes)
Line 651: Line 651:
27 28 29 30 31 24 25 26 27 28 29 30 28 29 30 26 27 28 29 30 31 23 24 25 26 27 28 29 28 29 30 31
27 28 29 30 31 24 25 26 27 28 29 30 28 29 30 26 27 28 29 30 31 23 24 25 26 27 28 29 28 29 30 31
31 30</pre>
31 30</pre>



=={{header|C}}==
=={{header|C}}==
Upper-case C version of the C Calendar task. Relies on the ability of most C compilers to specify #defines on the command line and declares the putchar function to avoid needing any #includes. E.g. for tcc.

<b>Note:</b> Historically, some UNIX systems were connected to upper-case only terminals, and users of those systems needed to write C programs. One could configure the terminal using the "stty" command, setting the olcuc and iuclc options to translate uppercase to lowercase on input, and convert lowercase to uppercase on output (although typically the setting was applied by the "getty" program so that logging in would be possible).
<b>Note:</b> Historically, some UNIX systems were connected to upper-case only terminals, and users of those systems needed to write C programs. One could configure the terminal using the "stty" command, setting the olcuc and iuclc options to translate uppercase to lowercase on input, and convert lowercase to uppercase on output (although typically the setting was applied by the "getty" program so that logging in would be possible).


So the text that was actually saved in the C source code would be lowercase, but it would appear on the terminal as uppercase.
So the text that was actually saved in the C source code would be lowercase, but it would appear on the terminal as uppercase.
<br>

This would also apply to any other language source or document.
<br>
<br>
Modern versions of Linux and MacOS have preserved this feature.
Modern versions of Linux and MacOS have preserved this feature.
<br>

<br>
However, the following is an actual upper-case only version of the C Calendar task.
It relies on the ability of most C compilers to allow #defines to be specified on the command line and also declares the putchar function to avoid needing any #includes (neither #define nor #include could be specified in upper-case without a non-standard pre-processor).
<br>
The program can be compiled with the following (substitute the name of your compiler for tcc):
<pre>
<pre>
tcc -DSTRUCT=struct -DCONST=const -DINT=int -DCHAR=char -DVOID=void -DMAIN=main -DIF=if -DELSE=else -DWHILE=while -DFOR=for -DDO=do -DBREAK=break -DRETURN=return -DPUTCHAR=putchar UCCALENDAR.c
tcc -DSTRUCT=struct -DCONST=const -DINT=int -DCHAR=char -DVOID=void -DMAIN=main -DIF=if -DELSE=else -DWHILE=while -DFOR=for -DDO=do -DBREAK=break -DRETURN=return -DPUTCHAR=putchar UCCALENDAR.c