473,698 Members | 2,084 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

reply the answer

Can we write a C programe with out a semicolon ? printing HELLOWORLD !

Jun 24 '07
105 3230
Groovy hepcat Keith Thompson was jivin' on Fri, 06 Jul 2007 08:11:16
-0700 in comp.lang.c.
Re: reply the answer's a cool scene! Dig it!
>ph******@alpha link.com.au.NO. SPAM (Peter 'Shaggy' Haywood) writes:
[...]
> Yes, I think you're right. I was confusing what C90 says about
non-void functions without a return statement (basically, the above)
with what C99 says (that it's not allowed). The code in question was
C90 conforming after all, I guess. And I stand, once again, corrected.

Where does C99 say that a non-void function without a return statement
is not allowed? The closest thing I can find is C99 6.9.1p12:

If the } that terminates a function is reached, and the value of
the function call is used by the caller, the behavior is
undefined.
Now I'm confused. Where did I read that it's not allowed, then?
Hell, maybe it was in a parallel universe or something. I just don't
know anymore.
>Note that the behavior is undefined only if the caller actually
attempts to uses the result.

Also, C99 6.8.6.4 says:

A return statement with an expression shall not appear in a
function whose return type is void. A return statement without an
expression shall only appear in a function whose return type is
void.

That's a constraint, but it says nothing about missing return
statements.
Perhaps I just need to stop posting nonsense and re-read the damn
thing (the standard... or at least n1124).

--

Dig the even newer still, yet more improved, sig!

http://alphalink.com.au/~phaywood/
"Ain't I'm a dog?" - Ronny Self, Ain't I'm a Dog, written by G. Sherry & W. Walker.
I know it's not "technicall y correct" English; but since when was rock & roll "technicall y correct"?
Jul 10 '07 #101
ph******@alphal ink.com.au.NO.S PAM (Peter 'Shaggy' Haywood) writes:
Groovy hepcat Keith Thompson was jivin' on Fri, 06 Jul 2007 08:11:16
-0700 in comp.lang.c.
Re: reply the answer's a cool scene! Dig it!
>>ph******@alph alink.com.au.NO .SPAM (Peter 'Shaggy' Haywood) writes:
[...]
>> Yes, I think you're right. I was confusing what C90 says about
non-void functions without a return statement (basically, the above)
with what C99 says (that it's not allowed). The code in question was
C90 conforming after all, I guess. And I stand, once again, corrected.

Where does C99 say that a non-void function without a return statement
is not allowed? The closest thing I can find is C99 6.9.1p12:

If the } that terminates a function is reached, and the value of
the function call is used by the caller, the behavior is
undefined.

Now I'm confused. Where did I read that it's not allowed, then?
Hell, maybe it was in a parallel universe or something. I just don't
know anymore.
[...]

One possible source of confusion is a change in C99.

C90 6.6.6.4 says:

Constraints

A return statement with an expression shall not appear in a
function whose return type is void.

C99 6.8.6.4 says:

Constraints

A return statement with an expression shall not appear in a
function whose return type is void. A return statement without an
expression shall only appear in a function whose return type is
void.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jul 10 '07 #102
Peter 'Shaggy' Haywood wrote:
Groovy hepcat Keith Thompson wrote:
.... snip ...
>
>Where does C99 say that a non-void function without a return
statement is not allowed? The closest thing I can find is C99
6.9.1p12:

If the } that terminates a function is reached, and the value
of the function call is used by the caller, the behavior is
undefined.

Now I'm confused. Where did I read that it's not allowed, then?
Hell, maybe it was in a parallel universe or something. I just
don't know anymore.
You just quoted it. Undefined behaviour is not quite usable.

--
<http://www.cs.auckland .ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfoc us.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com

Jul 11 '07 #103
CBFalconer said:
Peter 'Shaggy' Haywood wrote:
>Groovy hepcat Keith Thompson wrote:
... snip ...
>>
>>Where does C99 say that a non-void function without a return
statement is not allowed? The closest thing I can find is C99
6.9.1p12:

If the } that terminates a function is reached, and the value
of the function call is used by the caller, the behavior is
undefined.

Now I'm confused. Where did I read that it's not allowed, then?
Hell, maybe it was in a parallel universe or something. I just
don't know anymore.

You just quoted it. Undefined behaviour is not quite usable.
Nonsense. It's just not *universally* usable. The following function
exhibits undefined behaviour:

void printat(const char *s, unsigned char attr, int x, int y)
{
unsigned char *base = (unsigned char *)0xB8000000UL;
base += 160 * y;
base += 2 * x;
while(*s != '\0')
{
*base++ = *s++;
*base++ = attr;
}
}

And yet I have *used* such a function[1] in several programs, where it
turned out to be not only *usable* but also highly *useful*, even
though it invokes undefined behaviour and even though it is not
portable (and yes, even under MS-DOS, there are systems where it can
fail). And it's lightning-quick, too.

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jul 11 '07 #104
CBFalconer wrote, On 10/07/07 21:48:
Peter 'Shaggy' Haywood wrote:
>Groovy hepcat Keith Thompson wrote:
... snip ...
>>Where does C99 say that a non-void function without a return
statement is not allowed? The closest thing I can find is C99
6.9.1p12:

If the } that terminates a function is reached, and the value
of the function call is used by the caller, the behavior is
undefined.
Now I'm confused. Where did I read that it's not allowed, then?
Hell, maybe it was in a parallel universe or something. I just
don't know anymore.

You just quoted it. Undefined behaviour is not quite usable.
The behaviour is only undefined if the value is used. The following is
perfectly legal (requires no diagnostic and does not invoke UB):

#include <stdio.h>

int sily(void)
{
puts("Hello");
}

int main(void)
{
sily();
return 0;
}

gcc will give a warning (or even error) if poked hard enough, but with
only the options to ensure full compliance to a C standard and no extra
warnings (or errors) it will produce no diagnostic.
--
Flash Gordon
Jul 11 '07 #105
CBFalconer <cb********@yah oo.comwrites:
Peter 'Shaggy' Haywood wrote:
>Groovy hepcat Keith Thompson wrote:
... snip ...
>>
>>Where does C99 say that a non-void function without a return
statement is not allowed? The closest thing I can find is C99
6.9.1p12:

If the } that terminates a function is reached, and the value
of the function call is used by the caller, the behavior is
undefined.

Now I'm confused. Where did I read that it's not allowed, then?
Hell, maybe it was in a parallel universe or something. I just
don't know anymore.

You just quoted it. Undefined behaviour is not quite usable.
There's a huge difference between "not quite usable" and "not
allowed".

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jul 11 '07 #106

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

Similar topics

0
1657
by: Showcar | last post by:
Thank you for your interest in the Hendrick Motorsports Showcar Program. In an attempt to answer your questions more effectively and efficiently, we have developed this automatic response. If this reply does not satisfactorily answer your questions, we will gladly respond to you personally as soon as possible. · If you would like more information on how to book a showcar appearance, please provide us with as much information as possible,...
1
1201
by: sorCrer | last post by:
Hi Juan, Thanks for the reply! Unfortunately your answer didn't help me. If I don't 'Import' the custom class then I can't call any of it's functions. This problem goes away if I compile the .vb file first, and import the namespace and class with an import directive! It's almost as if the framework can't see the /code directory the way it should.
4
1206
by: K.N.Ranjit | last post by:
Hi to all friends out there.I am presently working in TCS and I am supposed to do the work given to me in line cordinates using VB.net.But over here I face a problem (ie) I want my coordinate (0,0) to start in the lower-left corner of my form instead of the default upper-left corner of the form.If anyone could provide me the solution I would be very contended. I could do the same in VB by just changing that scale top property which would...
19
1699
by: wcfinvader | last post by:
I have known this girl forever every since 3rd grade we are both in 10th grade now and I feel like I am in love with her and I want to ask her out but I dont know if I should call her tonight or this weekend or if I should wait until Monday at school to ask her. (We dont have school Friday Parent techer confernce). I know she likes me but not sure if she loves me. in 6th grade she asked me to go out with her and I didnt at the time...
23
2017
by: novice | last post by:
I dint find a proper group to post this, so i'm asking this question. If you think this question is irrelevent then dont answer, but i expect good replies from experts. I wondor, how these guys who answer to complicated questions have mastered C. I'm a beginner in C, and wondor how to master C. Should i study theory, or start writing programs? If i should start writing programs, What programs should i start with?
3
5408
by: Frank | last post by:
I am attempting to develop a solution where I handle bounced e-mails. I wish to field all bounced emails in a custom email account such a bounced@mycompany.com From the aricle at http://www.systemwebmail.com/faq/2.7.aspx, I gather I could use: mail.Headers.Add( "Reply-To", "alternate_email@mycompany.com" ); When I test this from a test web app, I don't seem to field a bounced email
0
1192
by: roberto | last post by:
Sorry, but posting a reply does no work (6 hours after the "successful" post the message is not shown)) so I decided to post it. This is a reply to a thread http://groups.google.pl/group/microsoft.public.dotnet.framework.webservices/browse_thread/thread/1de13b5ef20c837a/78006eaa8e840fd1#78006eaa8e840fd1 Web Service API is a minimal one, there is nothing to refactor. What I want is to hide complexities of the proxy from third-party...
1
1667
by: Karon Davis | last post by:
Hi, can someone tell me if it's possible to send delivery status notifications (or NDRs) to the Reply-To address (specified in CDOSYS script) rather than the FROM address? thanks.
0
8672
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
8600
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
9021
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...
1
8892
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
8860
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...
1
6518
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
5860
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();...
1
3038
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
2323
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.