Write a C Program which has least number of characters and prints "Hello G4EF" without quotes. This is not first submission winner but would wait for all submission and then the shortest would win. Criteria would be least number of characters and it should be a C Program
I googled and found this as the shortest possible. As, the source file is only 1 byte ! Steps : (1) Create a new empty file named : "void main(){puts(Hello, World!);}c.c" (2) Open the file with any text editor and write only one char "A" to the file and save it. ##That's our program Only 1 char content ! (3) To compile it, use gcc with flags "-DA=__FILE__ -Dc=// -istdio.h void*.c". Not sure if it works. I'll test and post.
1. Charater #include<stdio.h> main() {puts("Hello G4EF");} Total Character = 48 2. #include<stdio.h> main() {puts("Hello G4EF");} Save It = 4 KB
That's because the file is stored in blocks, and the smallest block size is 4KB. Select the file and press Alt-Enter and you'll see the actual file size displayed. Very good. And what is the source code of that C program? It's true Shabbir didn't actually say "and post the code here", but that could reasonably be implied, also how is he going to judge your code if he can't see it?
It can be verified on Windows also All chars in the file-name are perfectly fine on Windows XP. BTW, her is the source :: http://everything2.com/title/The+World%27s+Shortest+Hello+World And, I think xpi0t0s and/or someone else might verify and post the result here too.
I haven't said anything because I don't think it would work. But I don't have a Linux or MinGW installation handy to try it. Saswat, to convince me* you should post a screen shot that shows it working. Use four commands: ls cat <filename> <the gcc command> <invoke the executable so we can see the output> *Not that it's me that needs convincing. But I think this would convince anyone.
Thanx for accepting my answer :happy: But ... As I mentioned, "Not sure if it works". And as xpi0t0s thinks it won't work, it might not. I just read it here : http://everything2.com/title/The+World%27s+Shortest+Hello+World Anyway, one thing is clear from the code that it is not according to the latest ANSI C specs, 'cuz it still uses void main() and not int main(). Anyway, the shortest working (confirmed) "Hello G4EF" program in ANSI C will be : Code: main(){puts("Hello G4EF");} which is still the shortest (29 bytes) even if my previous answer is rejected NOTE that you don't need to do these : (*) #include <stdio.h> (*) int in-front of main. (*) return 0 (*) New lines at end of statements They reduce the code length further.
I think it won't work because there are missing quotes: Code: puts(Hello, World!) Apart from that though the principle of putting one character in the C file and using a -D to place the code is absolutely fine, in fact this is what one of the IOCCC winners did (although his file was 3 characters long: A;<eof>).