|
|
Line 130: |
Line 130: |
|
=={{header|C}}== |
|
=={{header|C}}== |
|
|
|
|
|
The following answers assume compilation using gcc 11.3.0 on ubuntu 22.04, without using any special options and ignoring the warnings that: |
|
The following answers assume compilation using gcc 11.3.0 on ubuntu 22.04, without using any special options and ignoring the warnings. |
|
|
|
|
|
⚫ |
The shortest possible program ( 26 bytes) to print the required string is: |
|
1. The default return type of 'main' is 'int'; and |
|
|
⚫ |
<syntaxhighlight lang="c">main(){ puts("Code Golf");}</syntaxhighlight> |
|
|
|
|
|
⚫ |
The size of the executable needed to run this is 15, 960 bytes. |
|
2. 'printf' is being implicitly declared (i.e. no explicit #include <stdio.h>). |
|
|
|
|
|
|
⚫ |
If the program itself cannot contain string or character literals, then the shortest program I've been able to come up with ( 48 bytes) is: |
⚫ |
The shortest possible program ( 28 bytes) to print the required string is: |
|
⚫ |
<syntaxhighlight lang="c">main(){ printf("Code Golf");}</syntaxhighlight> |
|
|
|
|
|
|
⚫ |
<syntaxhighlight lang="c"> a[]={ 0x65646f43, 0x6c6f4720, 102}; main() {puts( a);}</syntaxhighlight> |
⚫ |
The size of the executable needed to run this is 15, 968 bytes. |
|
|
|
|
|
|
⚫ |
The size of the executable needed is now 15, 992 bytes. |
⚫ |
If the program itself cannot contain string or character literals, then the shortest program I've been able to come up with ( 82 bytes) is: |
|
|
|
|
⚫ |
<syntaxhighlight lang="c"> main(){int c[]={ 37, 9, 2,3,70,33,9,10,0}; for( int i=0;i<9;++i) printf( "%c",c[i]^102);}</syntaxhighlight> |
|
|
|
|
⚫ |
The size of the executable needed is now 16, 016 bytes. |
|
|
|
|
|
|
Output in both cases: |
|
Output in both cases: |