Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > why i value doesn't change ?

Reply
Thread Tools

why i value doesn't change ?

 
 
Harald van Dijk
Guest
Posts: n/a
 
      11-28-2007
On Tue, 27 Nov 2007 15:08:09 -0800, Francine.Neary wrote:
> On Nov 27, 10:54 pm, (E-Mail Removed) (Kenny McCormack)
> wrote:
>> int fork(void) { puts("Try a spoon instead!"); }

>
> This invokes undefined behavior if the caller attempts to use the return
> value of a call to fork().


No, it is the attempt to use the return value of a call to fork() that
invokes undefined behaviour. "This", the function, is entirely valid.
 
Reply With Quote
 
 
 
 
pete
Guest
Posts: n/a
 
      11-28-2007
Marco Manfredini wrote:
>
> pete wrote:
>
> > Marco Manfredini wrote:
> >
> >> I'm just a curios visitor, bewildered by the customs of the local
> >> natives. Anyway, I could point out that this question *is* on-topic,
> >> because the OP found an external library function which seems to
> >> undermine C's memory model *completely*, an inexplicable behavior. A
> >> beginner may even wonder, if his/her inchoate proficiency of the
> >> language is the cause of a fallacy only resolvable by the courtesy of
> >> the knowing.

> >
> > As far as posted C code goes:
> > If posted C code can be part of the kind of
> > code that can be translated and executed
> > on any conforming C implementation, then it's on topic.

>
> A conforming implementation allows
> the user to use code that is declared
> in header files and defined elsewhere. Quiz: Judging only the behavior
> described by the OP, can this mysterious "fork()" function be
> implemented in ISO-C? If not, what does that mean? Undefined behavior?


It means fork is on topic in another newsgroup.
The problem is that most programmers
find "comp.lang.c" too easy to spell,
while finding a newsgroup where forks are on topic
is too difficult.

--
pete
 
Reply With Quote
 
 
 
 
pete
Guest
Posts: n/a
 
      11-28-2007
Willem wrote:
>
> Kenny wrote:
> ) In article <(E-Mail Removed)>,
> ) Willem <(E-Mail Removed)> wrote:
> )>Marco wrote:
> )>) Then please give an implementation of fork() in ISO-C.
> )>
> )>Why does the implementation have to be in ISO-C ?
> )
> ) If it isn't, we can't talk about it here.
>
> The original claim was that fork() somehow *broke* standard-C.
> I don't see how having to implement
> it in C has anything to do with it.


It has nothing to do with it.
Lots of standard C library functions
can't be implemented portably in C,
but they're all on topic.

You really shouldn't reply to "Kenny".
It's just a Markov text generator.

--
pete
 
Reply With Quote
 
Charlie Gordon
Guest
Posts: n/a
 
      11-29-2007
"CBFalconer" <(E-Mail Removed)> a crit dans le message de news:
http://www.velocityreviews.com/forums/(E-Mail Removed)...
> (E-Mail Removed) wrote:
>> (E-Mail Removed) (Kenny McCormack) wrote:
>>> CBFalconer <(E-Mail Removed)> wrote:
>>>> Marco Manfredini wrote:
>>>>
>>>>> Then please give an implementation of fork() in ISO-C.
>>>
>>>> There is no such thing. fork() is not defined in ISO-C. If it
>>>> was defined it would not be implementable within the language
>>>> (assuming the usual meaning).
>>>
>>> No, no, no. You've got it all wrong. As far as anyone in this
>>> NG is concerned, the following is a perfectly good implementaion
>>> of "fork()" and is absolutely to be considered as good or better
>>> than any other implementation of "fork()":
>>>
>>> int fork(void) { puts("Try a spoon instead!"); }

>>
>> This invokes undefined behavior if the caller attempts to use the
>> return value of a call to fork().

>
> Since puts always returns a non-zero int, it is easily corrected.


Non sequitur.

puts can return EOF or a non negative value, where do you get that it cannot
be zero?
This implementation of fork can be easily fixed in many ways: an easy one
consists in inserting the return keyword in front of puts.

--
Chqrlie.


 
Reply With Quote
 
CBFalconer
Guest
Posts: n/a
 
      11-30-2007
Charlie Gordon wrote:
> "CBFalconer" <(E-Mail Removed)> a crit:
>

.... snip ...
>
>> Since puts always returns a non-zero int, it is easily corrected.

>
> Non sequitur.
>
> puts can return EOF or a non negative value, where do you get that
> it cannot be zero? This implementation of fork can be easily
> fixed in many ways: an easy one consists in inserting the return
> keyword in front of puts.


I think I misread 'non-negative' as 'non-zero' in the following:

7.19.7.10 The puts function

Synopsis
[#1]
#include <stdio.h>
int puts(const char *s);

Description

[#2] The puts function writes the string pointed to by s to
the stream pointed to by stdout, and appends a new-line
character to the output. The terminating null character is
not written.

Returns

[#3] The puts function returns EOF if a write error occurs;
otherwise it returns a nonnegative value.

My mistake. Sorry. Well caught.

--
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>
Try the download section.



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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
why why why why why Mr. SweatyFinger ASP .Net 4 12-21-2006 01:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
A Paradise DNS address change? What change? There was no change. Tony Neville NZ Computing 7 09-22-2006 01:02 PM
Change the value of an attribute according to the value of another attribute patrizio.trinchini@googlemail.com XML 8 08-22-2006 02:53 PM
Radio Button lost it`s checked value after few time change value BobbyMy ASP .Net Web Controls 0 08-27-2005 03:04 AM



Advertisments