main()
{
int a = 1;
int c,d;
c = ++a + ++a + ++a;
printf("\n%d",a);
printf("\n%d ", c);
getch();
}
The above given code gives the value of "a" and "c" as 4 and 12 resp.
Can anyone tell me why it is so... 16 1294
ashu wrote:
>
main()
{
int a = 1;
int c,d;
c = ++a + ++a + ++a;
printf("\n%d",a);
printf("\n%d ", c);
getch();
}
The above given code gives the value of "a" and "c" as 4 and 12 resp.
Can anyone tell me why it is so...
http://docs.mandragor.org/files/Prog...-faq/q3.2.html
--
pete
ashu <as************@gmail.comwrites:
c = ++a + ++a + ++a;
The above given code gives the value of "a" and "c" as 4 and 12 resp.
Can anyone tell me why it is so...
Because you were unlucky.
If you were lucky, the compiler would have refused to compile this
source.
If you were using the compiler I have not yet written, it would have
deleted the source file and displayed the relevant part of the
standard (that explicitly describes this as Undefined Behaviour) in
high-contrast lettering until you passed a Turing test it administered
to ensure you understood the point.
mlp
On Apr 22, 2:35 am, Mark L Pappin <m...@acm.orgwrote:
ashu <ashishmoury...@gmail.comwrites:
c = ++a + ++a + ++a;
The above given code gives the value of "a" and "c" as 4 and 12 resp.
Can anyone tell me why it is so...
Because you were unlucky.
If you were lucky, the compiler would have refused to compile this
source.
If you were using the compiler I have not yet written, it would have
deleted the source file and displayed the relevant part of the
standard (that explicitly describes this as Undefined Behaviour) in
high-contrast lettering until you passed a Turing test it administered
to ensure you understood the point.
mlp
actually i want to abt one specific line
" c=++a + ++a + ++a;
how compiler calculate it and y? will it be different on different
compilers.
i think it should taken as
c= 2+3+4.
ashu wrote:
On Apr 22, 2:35 am, Mark L Pappin <m...@acm.orgwrote:
>>ashu <ashishmoury...@gmail.comwrites:
>>>c = ++a + ++a + ++a; The above given code gives the value of "a" and "c" as 4 and 12 resp.
>>>Can anyone tell me why it is so...
Because you were unlucky.
If you were lucky, the compiler would have refused to compile this source.
If you were using the compiler I have not yet written, it would have deleted the source file and displayed the relevant part of the standard (that explicitly describes this as Undefined Behaviour) in high-contrast lettering until you passed a Turing test it administered to ensure you understood the point.
actually i want to abt one specific line
" c=++a + ++a + ++a;
how compiler calculate it and y? will it be different on different
compilers.
i think it should taken as
c= 2+3+4.
Please don't use silly txtspk abbreviations on Usenet.
The line in question invokes undefined behaviour.
--
Ian Collins.
ashu wrote:
>
error 1, no #include <anything>
main()
error 2, no type for main, no specification of parameters.
{
int a = 1;
int c,d;
c = ++a + ++a + ++a;
error 3, undefined behaviour.
printf("\n%d",a);
printf("\n%d ", c);
error 4, no final '\n'
getch();
error 5, unknown function in std. C
error 6, failure to return a value.
}
The above given code gives the value of "a" and "c" as 4 and 12
resp. Can anyone tell me why it is so...
--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
cbfalconer at maineline.net
--
Posted via a free Usenet account from http://www.teranews.com
ashu wrote:
>
On Apr 22, 2:35 am, Mark L Pappin <m...@acm.orgwrote:
ashu <ashishmoury...@gmail.comwrites:
c = ++a + ++a + ++a;
The above given code gives the value
of "a" and "c" as 4 and 12 resp.
Can anyone tell me why it is so...
Because you were unlucky.
If you were lucky, the compiler would have refused to compile this
source.
If you were using the compiler I have not yet written, it would have
deleted the source file and displayed the relevant part of the
standard (that explicitly describes this as Undefined Behaviour) in
high-contrast lettering
until you passed a Turing test it administered
to ensure you understood the point.
mlp
actually i want to abt one specific line
" c=++a + ++a + ++a;
how compiler calculate it and y?
The compiler can do whatever it wants with that one specific line.
The variable (a), is read 3 times and modified 3 times
without an intervening sequence point.
Even though it seems as though the maximum value can be 12
if the initial value of (a) is 1
(a) is incremented 3 times to a value of 4
and then (4 + 4 + 4 == 12)
and that the minimum value can be 6
(++a) == 2, and then (2 + 2 + 2 == 6)
and then (a) is incremented 3 times to become 4
the case is that the C standard committee decided that
code like that is garbage and not worth the trouble of defining.
Read the document at the below URL: http://docs.mandragor.org/files/Prog...-faq/q3.8.html
--
pete
Mark L Pappin <ml*@acm.orgwrote in news:m3************@Claudio.Messina:
>
If you were using the compiler I have not yet written, it would have
deleted the source file and displayed the relevant part of the
standard (that explicitly describes this as Undefined Behaviour) in
high-contrast lettering until you passed a Turing test it administered
to ensure you understood the point.
Now that sounds like a compiler I'd be interested in :-)
Zero
pete <pf*****@mindspring.comwrote in
news:46***********@mindspring.com:
ashu wrote:
>> actually i want to abt one specific line " c=++a + ++a + ++a; how compiler calculate it and y?
The compiler can do whatever it wants with that one specific line.
actually the compiler can whatever it want with the whole program. Using
undefined behaviour anywhere in a program makes the whole thing undefined.
Zero
"CBFalconer" <cb********@yahoo.comha scritto nel messaggio
news:46***************@yahoo.com...
ashu wrote:
>main()
error 2, no type for main, no specification of parameters.
In C89 it's not an error, just bas style.
pete <pf*****@mindspring.comwrites:
ashu wrote:
>> main() { int a = 1; int c,d; c = ++a + ++a + ++a; printf("\n%d",a); printf("\n%d ", c); getch(); }
The above given code gives the value of "a" and "c" as 4 and 12 resp.
Can anyone tell me why it is so...
http://docs.mandragor.org/files/Prog...-faq/q3.2.html
Pete, did you post this URL to call attention to the apparent
copyright violation?
The *real* comp.lang.c FAQ is at <http://www.c-faq.com/>.
docs.mandragor.org appears to have an unauthorized copy of an earlier
version of it. The wording for question 3.2 differs from that in the
real FAQ.
Amazingly enough, mandragor.com even reproduces (and old version of)
Steve Summit's copyright message:
This collection of hypertext pages is Copyright 1995 by Steve
Summit. Content from the book "C Programming FAQs: Frequently
Asked Questions" (Addison-Wesley, 1995, ISBN 0-201-84519-9) is
made available here by permission of the author and the publisher
as a service to the community. It is intended to complement the
use of the published text and is protected by international
copyright laws. The content is made available here and may be
accessed freely for personal use but may not be published or
retransmitted without written permission.
I'll send Steve an e-mail message about this.
--
Keith Thompson (The_Other_Keith) 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"
pete <pf*****@mindspring.comwrites:
[...]
Read the document at the below URL:
http://docs.mandragor.org/files/Prog...-faq/q3.8.html
No, visit the *real* FAQ at <http://www.c-faq.comand read question
3.8. mandragor.org has a copy of an old version of the FAQ, probably
in violation of its copyright. I've notified the site's maintainer
and Steve Summit.
--
Keith Thompson (The_Other_Keith) 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"
Keith Thompson wrote:
>
pete <pf*****@mindspring.comwrites: http://docs.mandragor.org/files/Prog...-faq/q3.2.html
>
Pete, did you post this URL to call attention to the apparent
copyright violation?
No.
I couldn't remember the URL so I googled "clc faq", and I got: http://docs.mandragor.org/files/Prog.../C/clc_faq_en/
which says that it is "Steve Summit's home page"
>
The *real* comp.lang.c FAQ is at <http://www.c-faq.com/>.
docs.mandragor.org appears to have an unauthorized copy of an earlier
version of it. The wording for question 3.2 differs from that in the
real FAQ.
Amazingly enough, mandragor.com even reproduces (and old version of)
Steve Summit's copyright message:
This collection of hypertext pages is Copyright 1995 by Steve
Summit. Content from the book "C Programming FAQs: Frequently
Asked Questions" (Addison-Wesley, 1995, ISBN 0-201-84519-9) is
made available here by permission of the author and the publisher
as a service to the community. It is intended to complement the
use of the published text and is protected by international
copyright laws. The content is made available here and may be
accessed freely for personal use but may not be published or
retransmitted without written permission.
I'll send Steve an e-mail message about this.
--
pete
zero <ze**@this.hiwrites:
Mark L Pappin <ml*@acm.orgwrote:
>If you were using the compiler I have not yet written, it would have deleted the source file and displayed the relevant part of the standard (that explicitly describes this as Undefined Behaviour) in high-contrast lettering until you passed a Turing test it administered to ensure you understood the point.
Now that sounds like a compiler I'd be interested in :-)
And that's only the default, before you increase the severity of the
diagnostics.
It should be available for the DeathStation 9000 in mid-October 1993,
with other architectures following customer demand.
mlp
pete wrote, On 23/04/07 09:14:
Keith Thompson wrote:
>pete <pf*****@mindspring.comwrites:
>
http://docs.mandragor.org/files/Prog...-faq/q3.2.html
>Pete, did you post this URL to call attention to the apparent copyright violation?
No.
I couldn't remember the URL so I googled "clc faq", and I got: http://docs.mandragor.org/files/Prog.../C/clc_faq_en/
which says that it is "Steve Summit's home page"
They seem to have archived a version of his site, wrapped it in their
own page, and failed to acknowledge what they have done.
Steve's REAL home page is http://www.eskimo.com/~scs/ which has a
pointer to the correct location of the FAQ.
<snip>
>I'll send Steve an e-mail message about this.
Good. I would say this was a clear cut case of copyright violation. The
same probably applies to a lot of the stuff on mandragor.org
--
Flash Gordon
pete <pf*****@mindspring.comwrites:
Keith Thompson wrote:
>> pete <pf*****@mindspring.comwrites:
>
http://docs.mandragor.org/files/Prog...-faq/q3.2.html
>> Pete, did you post this URL to call attention to the apparent copyright violation?
No.
I couldn't remember the URL so I googled "clc faq", and I got: http://docs.mandragor.org/files/Prog.../C/clc_faq_en/
which says that it is "Steve Summit's home page"
Interesting. A Google search for "clc faq" (without the quotation
marks) doesn't turn up the actual FAQ anywhere in the top 100 hits.
But http://www.c-faq.com is the *first* hit in a search for "c faq" or
for "comp.lang.c faq". If you need to find the real FAQ, use one of
those search terms (or set a bookmark).
>The *real* comp.lang.c FAQ is at <http://www.c-faq.com/>. docs.mandragor.org appears to have an unauthorized copy of an earlier version of it. The wording for question 3.2 differs from that in the real FAQ.
Amazingly enough, mandragor.com even reproduces (and old version of) Steve Summit's copyright message:
This collection of hypertext pages is Copyright 1995 by Steve Summit. Content from the book "C Programming FAQs: Frequently Asked Questions" (Addison-Wesley, 1995, ISBN 0-201-84519-9) is made available here by permission of the author and the publisher as a service to the community. It is intended to complement the use of the published text and is protected by international copyright laws. The content is made available here and may be accessed freely for personal use but may not be published or retransmitted without written permission.
I'll send Steve an e-mail message about this.
I tried to contact Steve and the owner of the web site; the latter
bounced with a "mailbox is full" message. The site's main page says:
We're spending a lot of time in selecting the documentation
available here, especially because of the copyrights. If despite
our attention, some file we shouldn't redistribute are on this
website, please mail us quickly.
so hopefully this will be straightened out amicably.
--
Keith Thompson (The_Other_Keith) 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"
"Mark L Pappin" <ml*@acm.orgha scritto nel messaggio
news:m3************@Claudio.Messina...
zero <ze**@this.hiwrites:
>Mark L Pappin <ml*@acm.orgwrote:
>>If you were using the compiler I have not yet written, it would have deleted the source file and displayed the relevant part of the standard (that explicitly describes this as Undefined Behaviour) in high-contrast lettering until you passed a Turing test it administered to ensure you understood the point.
>Now that sounds like a compiler I'd be interested in :-)
And that's only the default, before you increase the severity of the
diagnostics.
What will it do when you increase it? :-) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: keith |
last post by:
This may seem simple, but I'm having a bit of trouble figuring out
exactly how to do it. I'm accessing a database through an ODBC link,
and I have a query that returns only jobs completed that day...
|
by: kmacon |
last post by:
I have a form that contains a command button. The command button's
OnClick event builds a report using the CreateReport and
CreateReportControl functions and then opens the main report. I set...
|
by: Jérôme de Lagausie |
last post by:
Hello,
In one hand, I've got a set of more than 130 different structures,
mostly rather simple (a set of simple data members such as int, long, char
, float ...)
sample :
#ifndef _H2_H_...
|
by: Gary Brower |
last post by:
Hi,
I am using VB.Net to create an ASP web form. My goal is to create a
master/detail web form that allows users to create new master and detail
records. For example the form would have header...
|
by: Justin Naidl |
last post by:
A group of friends and I are doing a RPG (role-playing game) maker for a
school project. It occured to us, however, that if you want the user to be
able to have almost complete control over the...
|
by: sanparab |
last post by:
I am a new user for MS Access 2003, I want to transfer a data of Fixed lenght text file into Access Tabel.
The data is contained of four Record Set those are as follows
1. The header record...
|
by: Mike Wilson |
last post by:
Dear group,
I have an invoice entry form, which is a simple Master fields / Detail grid.
The main summary information of the invoice are stored in one table in a
dataset, which is bound using a...
|
by: Ganesh |
last post by:
Hi There,
I've a GridView contains hyperlink in each row. If user click that link it
will open another detail page with all information. After seeing the details
user can go back to search...
|
by: Echooff3 |
last post by:
My application utilizes a dataset with a couple of One to Many relations. If the user adds a new record and adds information to the master part of the form and adds information to the detail part of...
|
by: BillG |
last post by:
I am developing a business app using asp.net that will have 2 different
types of forms, a list view of data and then a detail view. The list views
are placed on a content panel in a master page. ...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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,...
|
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...
|
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,...
| |