473,785 Members | 2,291 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Printing "hello , wolrd" with out using semicolon

Hi,
Can any body tell me how to print "hello,worl d" with out using semicolon

Thanks in advance ..
Bye
Prashanth Badabagni
Nov 14 '05
42 9901
Jeremy Yallop wrote:

Martin Dickopp wrote:
int main(void) { if (putchar((((mai n==main)+(main= =main))*((main= =
main)+(main==ma in)) * ((main==main)+( main==main)) * ((main==main)+
(main==main))* ((main==main)+( main==main)) * ((main==main)+( main==
main)))-(((main==main)+ (main==main))*( (main==main)+(m ain==main)))-
(main==main)), putchar((((main ==main)+(main== main))*((main== main)+
(main==main)) * ((main==main)+( main==main)))+( (main==main)+(m ain==
main))),exit(ma in!=main),main= =main){}}


That's undefined behaviour: exit() is implicitly declared by the call
as a function returning int, but the standard function exit() is
defined as returning void.


Nope. exit is defined as never returning, so there is no
behaviour to become undefined.

--
"I'm a war president. I make decisions here in the Oval Office
in foreign policy matters with war on my mind." - Bush.
"Churchill and Bush can both be considered wartime leaders, just
as Secretariat and Mr Ed were both horses." - James Rhodes.
Nov 14 '05 #31
CBFalconer <cb********@yah oo.com> writes:
Jeremy Yallop wrote:

That's undefined behaviour: exit() is implicitly declared by the call
as a function returning int, but the standard function exit() is
defined as returning void.


Nope. exit is defined as never returning, so there is no
behaviour to become undefined.


Nonsense. You are wrong for the same reason that anyone who
makes the same claim about main() is wrong.
--
"What is appropriate for the master is not appropriate for the novice.
You must understand the Tao before transcending structure."
--The Tao of Programming
Nov 14 '05 #32

On Tue, 11 May 2004, CBFalconer wrote:

Jeremy Yallop wrote:
Martin Dickopp wrote:
int main(void) { if (putchar((((mai n==main)+(main= =main))*((main= =
main)+(main==ma in)) * ((main==main)+( main==main)) * ((main==main)+
(main==main))* ((main==main)+( main==main)) * ((main==main)+( main==
main)))-(((main==main)+ (main==main))*( (main==main)+(m ain==main)))-
(main==main)), putchar((((main ==main)+(main== main))*((main== main)+
(main==main)) * ((main==main)+( main==main)))+( (main==main)+(m ain==
main))),exit(ma in!=main),main= =main){}}


That's undefined behaviour: exit() is implicitly declared by the call
as a function returning int, but the standard function exit() is
defined as returning void.


Nope. exit is defined as never returning, so there is no
behaviour to become undefined.


You should know better than that! One of the possible effects of
undefined behavior is the computer's actually coming backwards in
time to mess up the program before it even gets to the trouble spot...

Suppose 'exit' is defined with a calling convention such that
it expected to see one parameter on the stack, followed by a return
address which it will use to print a diagnostic message to the
user if 'errno' is set. Suppose further that to preserve register
real estate, 'int' values are returned by the caller's allocating
some (write-only) space on the stack prior to pushing its return
address and any arguments to the function. (Note that variadic
functions must be *really* perverse on this implementation! )
Now, we call 'exit' as if it is a regular function returning an
'int'. We push our return address, then a write-only buffer for
the return value, and then the argument 0. 'exit' tries to read our
buffer as if it were an address, and we get an exception. Ta-da!

HTH,
-Arthur
Nov 14 '05 #33
Ben Pfaff wrote:
CBFalconer <cb********@yah oo.com> writes:
Jeremy Yallop wrote:

That's undefined behaviour: exit() is implicitly declared by
the call as a function returning int, but the standard function
exit() is defined as returning void.


Nope. exit is defined as never returning, so there is no
behaviour to become undefined.


Nonsense. You are wrong for the same reason that anyone who
makes the same claim about main() is wrong.


But main will return sooner or later, and its return value will be
used somehow. This does not apply to exit.

--
"I'm a war president. I make decisions here in the Oval Office
in foreign policy matters with war on my mind." - Bush.
"Churchill and Bush can both be considered wartime leaders, just
as Secretariat and Mr Ed were both horses." - James Rhodes.
Nov 14 '05 #34
CBFalconer <cb********@yah oo.com> writes:
Ben Pfaff wrote:
CBFalconer <cb********@yah oo.com> writes:
Jeremy Yallop wrote:

That's undefined behaviour: exit() is implicitly declared by
the call as a function returning int, but the standard function
exit() is defined as returning void.

Nope. exit is defined as never returning, so there is no
behaviour to become undefined.


Nonsense. You are wrong for the same reason that anyone who
makes the same claim about main() is wrong.


But main will return sooner or later, and its return value will be
used somehow. This does not apply to exit.


Irrelevant. Read the standard. There is no difference between
the situations. Both instances are undefined.
--
int main(void){char p[]="ABCDEFGHIJKLM NOPQRSTUVWXYZab cdefghijklmnopq rstuvwxyz.\
\n",*q="kl BIcNBFr.NKEzjwC IxNJC";int i=sizeof p/2;char *strchr();int putchar(\
);while(*q){i+= strchr(p,*q++)-p;if(i>=(int)si zeof p)i-=sizeof p-1;putchar(p[i]\
);}return 0;}
Nov 14 '05 #35
"Arthur J. O'Dwyer" wrote:
On Tue, 11 May 2004, CBFalconer wrote:
Jeremy Yallop wrote:
Martin Dickopp wrote:
> int main(void) { if (putchar((((mai n==main)+(main= =main))*((main= =
> main)+(main==ma in)) * ((main==main)+( main==main)) * ((main==main)+
> (main==main))* ((main==main)+( main==main)) * ((main==main)+( main==
> main)))-(((main==main)+ (main==main))*( (main==main)+(m ain==main)))-
> (main==main)), putchar((((main ==main)+(main== main))*((main== main)+
> (main==main)) * ((main==main)+( main==main)))+( (main==main)+(m ain==
> main))),exit(ma in!=main),main= =main){}}

That's undefined behaviour: exit() is implicitly declared by the call
as a function returning int, but the standard function exit() is
defined as returning void.


Nope. exit is defined as never returning, so there is no
behaviour to become undefined.


You should know better than that! One of the possible effects of
undefined behavior is the computer's actually coming backwards in
time to mess up the program before it even gets to the trouble spot...

Suppose 'exit' is defined with a calling convention such that
it expected to see one parameter on the stack, followed by a return
address which it will use to print a diagnostic message to the
user if 'errno' is set. Suppose further that to preserve register
real estate, 'int' values are returned by the caller's allocating
some (write-only) space on the stack prior to pushing its return
address and any arguments to the function. (Note that variadic
functions must be *really* perverse on this implementation! )
Now, we call 'exit' as if it is a regular function returning an
'int'. We push our return address, then a write-only buffer for
the return value, and then the argument 0. 'exit' tries to read our
buffer as if it were an address, and we get an exception. Ta-da!


We can agree on don't do dat, and that this whole thread is silly
and totally without redeeming features, but ...

Why can't we just use K&R source, not needing any prototypes, and
which has never heard the word 'void'? The need to handle such
prevents your mechanism above, IMO. Since the system is using
implicit int it must be C90, not C99.

--
"I'm a war president. I make decisions here in the Oval Office
in foreign policy matters with war on my mind." - Bush.
"Churchill and Bush can both be considered wartime leaders, just
as Secretariat and Mr Ed were both horses." - James Rhodes.

Nov 14 '05 #36
ai***@acay.com. au (Peter Nilsson) wrote:
"Arthur J. O'Dwyer" <aj*@nospam.and rew.cmu.edu> wrote in message
#define P(x) printf(#x
#define L(x) #x
#define S L(| |)[!Z]
int f(int l,int i){if((i=l,!Z)& &l==Z&&P(%c%c%d \n),S,S,Z)&&f
(++i,i)){}else if(--l==Z&&P(\n))&&f (++i,i)){}else if(--l==Z


The \ in \n is not at the end of a line, not part of a character or
string literal, not part of a universal character, not part of an
include header, and does not constitute a punctuator or other
preprocessor token.


Macro processing, including # stringising macros, is done in translation
phase 4; escape sequences are translated in phase 5. AFAICT this is
enough to ensure that the above is legal (at least in this regard!),
since by the time the backslash is seen, it _is_ part of a string
literal.

Richard
Nov 14 '05 #37
"Arthur J. O'Dwyer" <aj*@nospam.and rew.cmu.edu> wrote:
#include <stdio.h>
#include <stdlib.h>
#define Z ((int)NULL)
#define P(x) printf(#x
#define L(x) #x
#define S L(| |)[!Z]
int f(int l,int i){if((i=l,!Z)& &l==Z&&P(%c%c%d \n),S,S,Z)&&f
(++i,i)){}else if(--l==Z&&P(\n))&&f (++i,i)){}else if(--l==Z
&&P(%c%c%d\n),S ,S,Z)&&f(++i,i) ){}else if(--l==Z&&P(%c/\n),S
)&&f(++i,i)){}e lse if(exit(Z),Z){} }int main(){if(f(Z,Z )){}}


Alas, there is another, quite serious, bug in this program... it invokes
undefined behaviour! It calls f(++i,i) four times, each time modifying
the object i and accessing it for another purpose without an intervening
sequence point - that's a separator, not a comma operator! Fortunately,
this can easily be solved by changing all of these calls to f(++i,l).

Richard
Nov 14 '05 #38
On Mon, 10 May 2004 22:12:34 +0200,
Martin Dickopp <ex************ ****@zero-based.org> wrote
in Msg. <cu************ *@zero-based.org>
Jeremy Yallop <je****@jdyallo p.freeserve.co. uk> writes:
Martin Dickopp wrote:
int main(void) { if (putchar((((mai n==main)+(main= =main))*((main= =
main)+(main==ma in)) * ((main==main)+( main==main)) * ((main==main)+
(main==main))* ((main==main)+( main==main)) * ((main==main)+( main==
main)))-(((main==main)+ (main==main))*( (main==main)+(m ain==main)))-
(main==main)), putchar((((main ==main)+(main== main))*((main== main)+
(main==main)) * ((main==main)+( main==main)))+( (main==main)+(m ain==
main))),exit(ma in!=main),main= =main){}}


That's undefined behaviour: exit() is implicitly declared by the call
as a function returning int, but the standard function exit() is
defined as returning void.


Good catch. The only solution I can think of is to rely on the
"implicitly return 0 from main" behavior in C99.


How about (int)exit() ?

--Daniel

--
"With me is nothing wrong! And with you?" (from r.a.m.p)
Nov 14 '05 #39
Daniel Haude <ha***@physnet. uni-hamburg.de> writes:
On Mon, 10 May 2004 22:12:34 +0200,
Martin Dickopp <ex************ ****@zero-based.org> wrote
in Msg. <cu************ *@zero-based.org>
Jeremy Yallop <je****@jdyallo p.freeserve.co. uk> writes:
Martin Dickopp wrote:
int main(void) { if (putchar((((mai n==main)+(main= =main))*((main= =
main)+(main==ma in)) * ((main==main)+( main==main)) * ((main==main)+
(main==main))* ((main==main)+( main==main)) * ((main==main)+( main==
main)))-(((main==main)+ (main==main))*( (main==main)+(m ain==main)))-
(main==main)), putchar((((main ==main)+(main== main))*((main== main)+
(main==main)) * ((main==main)+( main==main)))+( (main==main)+(m ain==
main))),exit(ma in!=main),main= =main){}}

That's undefined behaviour: exit() is implicitly declared by the call
as a function returning int, but the standard function exit() is
defined as returning void.


Good catch. The only solution I can think of is to rely on the
"implicitly return 0 from main" behavior in C99.


How about (int)exit() ?


That doesn't help, and wouldn't have any effect anyway, as `exit'
doesn't return. The problem is that the behavior becomes undefined as
soon as an undeclared (or "implictly declared") function returning
anything but `int' is /called/.

Martin
--
,--. Martin Dickopp, Dresden, Germany ,= ,-_-. =.
/ ,- ) http://www.zero-based.org/ ((_/)o o(\_))
\ `-' `-'(. .)`-'
`-. Debian, a variant of the GNU operating system. \_/
Nov 14 '05 #40

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

Similar topics

33
5582
by: ankursinha | last post by:
Hi, Is it possible to write a C program that prints "Hello World" on screen without having a single semi-colon in the entire program? The extra constraint here is that u r not allowed to use if,while,switch etc. So far,i figured this could be done by insertint the printf statement in main as shown: int main(int argc=printf("Hello world")
51
4156
by: Spidey | last post by:
for(;0;) printf("hello"); even the condition s wrong i get a hello printed on the screen y s this happening
0
10357
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10104
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9959
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
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
7510
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
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5397
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
5532
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.