473,791 Members | 3,137 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can This C Code Compile Under g++

The code at the bottom is obfuscated c and was a category winner of the
1989 IOCCC
http://www.ioccc.org/1989/roemer.c
Does anyone have a trick to make it compile under g++? Thanks.
char
_3141592654[3141
],__3141[3141];_314159[31415],_3141[31415];main(){registe r char*
_3_141,*_3_1415 , *_3__1415; register int
_314,_31415,__3 1415,*_31,
_3_14159,__3_14 15;*_3141592654 =__31415=2,_314 1592654[0][_3141592654
-1]=1[__3141]=5;__3_1415=1;d o{_3_14159=_314 =0,__31415++;fo r( _31415
=0;_31415<(3,14-4)*__31415;_314 15++)_31415[_3141]=_314159[_31415]= -
1;_3141[*_314159=_3_141 59]=_314;_3_141=_3 141592654+__3_1 415;_3_1415=
__3_1415 +__3141;for (_31415 = 3141-
__3_1415 ; _31415;_31415--
,_3_141 ++, _3_1415++){_314
+=_314<<2 ; _314<<=1;_314+=
*_3_1415;_31 =_314159+_314;
if(!(*_31+1) )* _31 =_314 /
__31415,_314 [_3141]=_314 %
__31415 ;* ( _3__1415=_3_141
)+= *_3_1415 = *_31;while(*
_3__1415 >= 31415/3141 ) *
_3__1415+= - 10,(*--_3__1415
)++;_314=_314 [_3141]; if ( !
_3_14159 && * _3_1415)_3_1415 9
=1,__3_1415 = 3141-_31415;}if(
_314+(__31415 >>1)>=__31415 )
while ( ++ * _3_141==3141/314
)*_3_141--=0 ;}while(_3_1415 9
) ; { char * __3_14= "3.1415";
write((3,1), (--*__3_14,__3_14
),(_3_14159 ++,++_3_14159)) +
3.1415926; } for ( _31415 = 1;
_31415<3141- 1;_31415++)writ e(
31415% 314-( 3,14),_31415926 54[
_31415 ] + "0123456789","3 14"
[ 3]+1)-_314; puts((*_3141592 654=0
,_3141592654)) ;_314= *"3.141592"; }

Aug 19 '05 #1
4 1533
Jack wrote:
The code at the bottom is obfuscated c and was a category winner of
the 1989 IOCCC
http://www.ioccc.org/1989/roemer.c
Does anyone have a trick to make it compile under g++? Thanks.
...


No, the code won't compile under current compilers. Too much non-
standard stuff in it.

V
Aug 19 '05 #2
Victor Bazarov wrote:
Jack wrote:
The code at the bottom is obfuscated c and was a category winner of
the 1989 IOCCC
http://www.ioccc.org/1989/roemer.c
Does anyone have a trick to make it compile under g++? Thanks.
...


No, the code won't compile under current compilers. Too much non-
standard stuff in it.

V


gcc 4.0 will compile this source once the three or so stray space
characters that are splitting integer constants into two tokens are
removed. These spaces were were apparently inserted by the posting
software and are not part of the original C program.

Note that this is a C (not C++) program and should be saved to a file
with ".c" extension. The gcc compiler when compiling this code does
issue a few warnings about implicit int declarations, but these
warnings are not errors in C, apparently. Also I cannot get the built
program to run without crashing, so I may look further into the problem
there. These obfuscated C programs, though often difficult to tell what
they are doing from their source code (no kidding), were supposed to do
something useful when they did run.

Greg

Aug 19 '05 #3
Jack wrote:
The code at the bottom is obfuscated c and was a category winner of the
1989 IOCCC
http://www.ioccc.org/1989/roemer.c
Does anyone have a trick to make it compile under g++? Thanks.


g++? It's a C program. It compiles just fine in gcc (v3.4.4). It
doesn't run (segfault), but compiles. Is there a reason why you need to
compile it as C++ instead of C?
Aug 19 '05 #4
Greg wrote:

[ ... ]
These obfuscated C programs, though often difficult to tell what
they are doing from their source code (no kidding), were supposed to do
something useful when they did run.


In this case "useful" would be stretching it a bit -- all it does is
compute e (the base of natural logarithms) to some inordinate level of
precision.

--
Later,
Jerry.

The universe is a figment of its own imagination.

Aug 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
5939
by: Hung Jung Lu | last post by:
Hi, I know people have talked about it before, but I am still really confused from reading the old messages. When I talk about code blocks, I am not talking about Lisp/Ruby/Perl, so I am not making comparisons. If you have a file, in Python you could do:
242
13462
by: James Cameron | last post by:
Hi I'm developing a program and the client is worried about future reuse of the code. Say 5, 10, 15 years down the road. This will be a major factor in selecting the development language. Any comments on past experience, research articles, comments on the matter would be much appreciated. I suspect something like C would be the best based on comments I received from the VB news group. Thanks for the help in advance James Cameron
13
2051
by: AFKAFB | last post by:
Hi Sometimes when i edit previously saved VBA code e.g. To update field names etc the revised code does not work. Even if i copy and paste in a previous version it does not work. The only solution seems to be to delete the existing code, re-type ir word for word and hey presto it works. Of course you might think typo or something but its like Access seems
253
2785
by: James Cameron | last post by:
Hi I'm developing a program and the client is worried about future reuse of the code. Say 5, 10, 15 years down the road. This will be a major factor in selecting the development language. Any comments on past experience, research articles, comments on the matter would be much appreciated. I suspect something like C would be the best based on comments I received from the VB news group. Thanks for the help in advance James Cameron
3
2231
by: farseer | last post by:
i am getting "error C2057: expected constant expression" with the following code: ifstream f( argv ); f.seekg( 0, ios::end ); const long fSize = f.tellg(); f.close(); char content;
0
9669
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9515
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9029
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5431
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4110
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3718
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2916
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.