473,899 Members | 3,039 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 9916
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
5595
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
4198
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
9997
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
11272
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...
0
10863
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10494
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
9666
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
8039
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
6081
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4300
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3317
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.