comp.lang.c - 22 new messages in 11 topics - digest
comp.lang.c
http://groups.google.com/group/comp.lang.c?hl=en
Today's topics:
* how can i do ? - 3 messages, 3 authors
http://groups.google.com/group/comp.lang.c/t/2e7deee5098ae0f4?hl=en
* very hard for me what is the way to solv ?? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/1b74f40285b6a61f?hl=en
* send me the solution. - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/6c55c6c30a2fbd4d?hl=en
* what is the solution - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c/t/7cb93cca8b35784a?hl=en
* Newbie question: accessing global variable on multiprocessor - 1 messages, 1
author
http://groups.google.com/group/comp.lang.c/t/1c98f0aeb9e1ec74?hl=en
* plz give me solution - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c/t/0b1f8437097d2636?hl=en
* Comparision of C Sharp and C performance - 4 messages, 2 authors
http://groups.google.com/group/comp.lang.c/t/4cf78a2afa73b77a?hl=en
* need the solution - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c/t/40d72da494945b01?hl=en
* problem - 4 messages, 4 authors
http://groups.google.com/group/comp.lang.c/t/e2f69c6c3d571020?hl=en
* arithmetic on a void * pointer - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/451b17d19dcc5236?hl=en
* a gift for the mortensens - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/1911197d173cd869?hl=en
==============================================================================
TOPIC: how can i do ?
http://groups.google.com/group/comp.lang.c/t/2e7deee5098ae0f4?hl=en
==============================================================================
== 1 of 3 ==
Date: Sat, Jan 9 2010 11:11 pm
From: Ian Collins
wahid wrote:
> • Write a program that will take an integer
> number n input from the user, and then
> output the value of the sum of the series
> • S = 12 + 22 + 32+….. + n2
Solve the problem on paper, then convert it to code, then post your
attempt if you have problems.
Asking people to do your homework is a great way to learn absolutely
nothing and fail your exams.
--
Ian Collins
== 2 of 3 ==
Date: Sat, Jan 9 2010 11:19 pm
From: wahid
On Jan 10, 1:05 pm, wahid <wahid.1...@gmail.com> wrote:
> • Write a program that will take an integer
> number n input from the user, and then
> output the value of the sum of the series
> • S = 1^2 + 2^2 + 3^2+….. + n^2
== 3 of 3 ==
Date: Sun, Jan 10 2010 12:10 am
From: Seebs
On 2010-01-10, wahid <wahid.1144@gmail.com> wrote:
> ? Write a program that will take an integer
> number n input from the user, and then
> output the value of the sum of the series
> ? S = 12 + 22 + 32+?.. + n2
You never post thank-you notes to the people who do your homework, why is
that?
-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
==============================================================================
TOPIC: very hard for me what is the way to solv ??
http://groups.google.com/group/comp.lang.c/t/1b74f40285b6a61f?hl=en
==============================================================================
== 1 of 1 ==
Date: Sat, Jan 9 2010 11:15 pm
From: wahid
• The Tower of Hanoi or Towers of Hanoi is a
mathematical game or puzzle. It consists of three
rods, and a number of disks of different sizes
which can slide onto any rod.
• The objective of the puzzle is to move the entire
stack to another rod, obeying the following rules:
– Only one disk may be moved at a time.
– Each move consists of taking the upper disk from one
of the rods and sliding it onto another rod, on top of
the other disks that may already be present on that
rod.
– No disk may be placed on top of a smaller disk.
• Using recursion, write a program, that would
solve the tower of Hanoi Problem.
• Inputs: Number of Disks, Name of the three
pegs ( Peg on which initially all the disks rest is
input peg, peg on which finally all disks will lie
is output peg, the third peg is the other peg)
(Hint: think recursively, what if there were only two disks?
and what if the N-1 small disks where combined into a single disk?)
Sample Output:
Enter Input peg: 1
Enter output peg :2
Enter other peg : 3
Enter the number of disks :3
Tower of hanoi Solution :
Move Disk from Peg 1 to Peg 2
Move Disk from Peg 1 to Peg 3
Move Disk from Peg 2 to Peg 3
Move Disk from Peg 1 to Peg 2
Move Disk from Peg 3 to Peg 1
Move Disk from Peg 3 to Peg 2
Move Disk from Peg 1 to Peg 2
==============================================================================
TOPIC: send me the solution.
http://groups.google.com/group/comp.lang.c/t/6c55c6c30a2fbd4d?hl=en
==============================================================================
== 1 of 1 ==
Date: Sat, Jan 9 2010 11:15 pm
From: Ian Collins
wahid wrote:
> • Using getch() command, write a program that
C doesn't have a "getch() command".
Are you incapable of doing anything for your self?
--
Ian Collins
==============================================================================
TOPIC: what is the solution
http://groups.google.com/group/comp.lang.c/t/7cb93cca8b35784a?hl=en
==============================================================================
== 1 of 2 ==
Date: Sat, Jan 9 2010 11:16 pm
From: Ian Collins
wahid wrote:
> • Write a program
There's a novel idea, why don't you give it a try?
--
Ian Collins
== 2 of 2 ==
Date: Sat, Jan 9 2010 11:22 pm
From: Francis Glassborow
wahid wrote:
> � Write a program, that would take a number n
> from user, and then output the square and
> cube of first n natural numbers.
>
> Sample Output
> � Enter a number: 5
> � Output for 1: square 1, cube 1
> � Output for 2: square 4, cube 8
> � Output for 3: square 9, cube 27
> � Output for 4: square 16, cube 64
> � Output for 5: square 25, cube 125
This is the fourth problem you have posted here without any added
material from you.
Either you are an unbelievably lazy student, or you are too stupid to be
studying programming or you are an extremely bad troll.
If you genuinely want help, try producing your attempts at answering the
problems you are flooding us with. Post your code and we will do our
best to explain the errors.
==============================================================================
TOPIC: Newbie question: accessing global variable on multiprocessor
http://groups.google.com/group/comp.lang.c/t/1c98f0aeb9e1ec74?hl=en
==============================================================================
== 1 of 1 ==
Date: Sat, Jan 9 2010 11:20 pm
From: Nobody
On Sat, 09 Jan 2010 19:02:38 +0100, lacos wrote:
>> note that, for shared variables, you would want to mark them 'volatile'
>> (this is a keyword which serves this purpose, among others). basically, this
>> just tells the compiler to read from and write changes directly to memory,
>> rather than have them likely sit around in a register somewhere.
>
> I sincerely believe that you're wrong. This is a very frequent fallacy
> (I hope I'm using the right word). volatile in C has nothing to do with
> threads. Volatile is what the standard defines it to be. See
Notably, the standard states that reading from a "volatile" variable is a
sequence point, while reading from non-volatile variables isn't.
The more significant issue is that a sequence point isn't necessarily what
people expect. The specification only describes the *abstract* semantics,
which doesn't have to match what actually occurs at the hardware level.
AFAIK, there are only two situations where you can say "if this variable
is declared "volatile", this code will behave in this way; if you omit the
qualifier, it's undefined or implementation-defined behaviour". One
case relates to setjmp()/longjmp(), the other to signal().
And even if the compiler provides the "assumed" semantics for "volatile"
(i.e. it emits object code in which read/write of volatile variables
occurs in the "expected" order), that doesn't guarantee that the processor
itself won't re-order the accesses.
==============================================================================
TOPIC: plz give me solution
http://groups.google.com/group/comp.lang.c/t/0b1f8437097d2636?hl=en
==============================================================================
== 1 of 2 ==
Date: Sat, Jan 9 2010 11:22 pm
From: wahid
• Write a program, that will have letter grade as
input of 3 subjects, and their corresponding
credit hour, and calculate the CGPA based on
those three subjects. (Use getch to input letter
grades) The Grade Point Associated with the
letter grades is: A = 4.0, B = 3.5, C = 3.0, D =
2.5, F = 0.0
CGPA = ( ∑CHi GPi ) / (∑CHi )
CH = Credit Hours
GP = Grade Point
• Enter Letter grade 1: A
• Enter Credit hours: 1.5
• Enter Letter grade 1: C
• Enter Credit hours: 3
• Enter Letter grade 1: B
• Enter Credit hours: 3
• CGPA = 3.40000
== 2 of 2 ==
Date: Sat, Jan 9 2010 11:29 pm
From: spinoza1111
On Jan 10, 3:22 pm, wahid <wahid.1...@gmail.com> wrote:
> • Write a program, that will have letter grade as
> input of 3 subjects, and their corresponding
> credit hour, and calculate the CGPA based on
> those three subjects. (Use getch to input letter
> grades) The Grade Point Associated with the
> letter grades is: A = 4.0, B = 3.5, C = 3.0, D =
> 2.5, F = 0.0
>
> CGPA = ( ∑CHi GPi ) / (∑CHi )
>
> CH = Credit Hours
> GP = Grade Point
>
> • Enter Letter grade 1: A
> • Enter Credit hours: 1.5
> • Enter Letter grade 1: C
> • Enter Credit hours: 3
> • Enter Letter grade 1: B
> • Enter Credit hours: 3
> • CGPA = 3.40000
We don't do homework assignments here. Instead, we fight each other
about C.
==============================================================================
TOPIC: Comparision of C Sharp and C performance
http://groups.google.com/group/comp.lang.c/t/4cf78a2afa73b77a?hl=en
==============================================================================
== 1 of 4 ==
Date: Sat, Jan 9 2010 11:23 pm
From: spinoza1111
On Jan 10, 12:53 pm, Ben Bacarisse <ben.use...@bsb.me.uk> wrote:
> spinoza1111<spinoza1...@yahoo.com> writes:
> > On Jan 10, 1:19 am, Ben Bacarisse <ben.use...@bsb.me.uk> wrote:
> >>spinoza1111<spinoza1...@yahoo.com> writes:
> >> > On Jan 9, 10:33 am, Ben Bacarisse <ben.use...@bsb.me.uk> wrote:
> >> >>spinoza1111<spinoza1...@yahoo.com> writes:
> >> >> > On Jan 7, 11:08 am, Seebs <usenet-nos...@seebs.net> wrote:
> >> >> >> On 2010-01-07, Ben Bacarisse <ben.use...@bsb.me.uk> wrote:
>
> >> >> >> > ... For example, listing 10 in chapter 10 shows:
>
> >> >> >> > #define ABS(a) (a) < 0 ? -(a) : (a)
>
> >> >> >> > which might be there to show how /not/ to write a macro (please tell
> >> >> >> > me it is).
>
> >> >> >> You lose.
>
> >> >> >> "When this program is compiled, a in the macro definition will be
> >> >> >> substituted with the values -1 and 1. The parentheses that enclose
> >> >> >> a ensure proper substitution in all cases. For example, if the
> >> >> >> parentheses around a were removed, this expression:
> >> >> >> ABS(10-20)
> >> >> >> would be converted to
> >> >> >> 10-20 < 0 ? -10-20 : 10-20
> >> >> >> after macro replacement and would yield the wrong result."
>
> >> >> >> So, yeah, "all cases" meaning "all cases where the macro is not used in a
> >> >> >> larger expression".
> >> <snip>
> >> >> Why would
> >> >> someone suggest that ABS might be written that way? It will trip
> >> >> every beginner up.
>
> >> > Herb should have known the rule; he probably did know the rule.
> >> > However, most of his audience works in shops where rules in excess of
> >> > the language are known as "standards", and in these shops, employees
> >> > who cultivate their own approaches (including approaches that might be
> >> > recommended by people who consider themselves hotshots) are terminated
> >> > as "not part of the team". Therefore, it seems that Schildt and/or his
> >> > editors decided not to include a variety of "coding standards" that
> >> > have evolved because of the poor design of C.
>
> >> What logic lead him to cover one important aspect of function-like
> >> macros (putting parentheses round the parameters) and exclude another
> >> (parentheses round the whole expression)? It look to me like a simple
> >> mistake.
>
> > He didn't want to explain "my" 1990 rule (parenthesize formal
> > parameters in macro definitions, decide whether to return an
> > expression or a statement, return nothing else, if you return an
> > expression return it in its own set of round parentheses, if you
> > return a statement return the statement list in its own set of braces)
> > because there might have been counter-examples and the rule is rather
> > complicated.
>
> > To be able to understand it, the programmer has to know the difference
> > between a formal and an actual parameter and Herb could not assume
> > this knowledge in his readers.
>
> This is nonsense. It does not fit the facts: he does explain the part
> you think is too complex -- what you call the actual/formal parameter
...which IS the actual/formal distinction...
> distinction. He leaves out the simple bit that would make his ABS
> example usable.
>
> He sensibly makes no mention of the statement part of your rule
> because there is a better options available: the do ... while (0)
> idiom.
That's a silly idiom, although you're smart enough to see the need we
both address. I can think of no earthy reason why
#DEFINE GROSS2NET do net = gross - tax; while(0)
is preferable to
#DEFINE GROSS2NET { net = gross - tax; }
You may be smart enough to provide a reason why I should use null
while, which forces the maintenance programmer to go through several
levels of mental processing ("duh me see while why is that: is dis a
loop: oooooh no because while is false: is dis a nop: no, because it
is one trip: how cleverly stupid, how stupidly clever, reason in
madness"). My example same as yours can be plugged into any context
that allows a statement, but results in less useless thinking.
One assumption here is that of self-presence but the fact is that
truly intelligent people often have somewhat longer seek times than
mediocre fellows. For example, John Horton Conway of Princeton, the
mathematician who invented the Game of Life, says he forgets whether
he's proved theorems so simply proves them again.
Whereas for the lower middle class, intelligence is measured by
clerkish speed, as if we all must scramble to do the bidding of our
betters. This is a slave morality you ask me.
>
> <snip>
>
> >> >> Code like that does not help anyone who has to deal with C in a real
> >> >> job. People like that need correct examples and models of good
> >> >> style. Why, for example, is he using 'gets'; C's worst function (and
> >> >> an officially deprecated one) if he is just trying to help people muddle
> >> >> though with this terrible language?
>
> >> > Don't blame Herb for the cowardice of C standards writers who won't
> >> > get rid of bad features once and for all when this might harm the
> >> > profits of vendors.
>
> >> It's gone. The next C standard will not have gets. If there is ever
> >> a 5th edition, presumably the code will be corrected to remove
> >> repeated use of a deprecated function (85 uses).
>
> > Pray, what is gets() replaced with?
>
> Nothing. Of course you can write it in a line or two so there is no
> loss if someone wants to perpetuate the problem.
>
> >> But that is not the point. The world is changed by education not
> >> standards committees. Educators should take the lead in teaching the
> >> best practise.
>
> > They do. They say "don't use C, use Java".
>
> I thought we were talking about Herbert Schildt. At least I was.
> Writing four editions of a C text does not seem like a good way to say
> "don't use C".
Only if the middle class fantasy of "freedom" obtains, but the fact is
that the white collar worker is directed to work in C.
>
> <snip>
> --
> Ben.
== 2 of 4 ==
Date: Sat, Jan 9 2010 11:27 pm
From: spinoza1111
On Jan 9, 11:46 pm, Richard Heathfield <r...@see.sig.invalid> wrote:
> spinoza1111wrote:
> > On Jan 9, 5:04 pm, Richard Heathfield <r...@see.sig.invalid> wrote:
> >> spinoza1111wrote:
> >>> On Jan 9, 10:33 am, Ben Bacarisse <ben.use...@bsb.me.uk> wrote:
> >> <snip>
>
> >>>> I think you've missed the point. The parentheses around (a) are not
> >>>> the issue because they are, of course, correct. The problem is the
> >>>> lack of parentheses around the conditional expression.
> >>> Correctomundo: the conditional expression violates "my" rule, which I
> >>> developed in 1990, that "each macro that intends to return an
> >>> EXPRESSION must return an EXPRESSION surrounded by PARENTHESES: each
> >>> macro that intends to return a STATEMENT must return a STATEMENT LIST
> >>> surrounded by BRACES".
> >> Macros don't return either expressions or statements.
>
> > Then you misunderstand their proper use despite your "expertise" in C.
>
> It's possible, but I don't think it very likely.
>
> > If a macro returns anything else besides an expression or statement it
> > can cause errors.
>
> Macros don't return expressions, statements, or *anything else*.
>
> <snip>
>
> >> Functions return expressions (never statements).
>
> > Wow, I'll alert the media. Functions return expressions? This is
> > nonsense. Functions return the values of expressions.
>
> Right. Well done. I misspoke, and you caught me. That's one brownie
> point to you. Treasure it.
You are a swine, Heathfield. You expect to be forgiven for what you
claim to be typos but are not nearly as gracious with newbies and
people who attract your swinish anger because they know more than you.
>
> <nonsense snipped>
>
> --
> Richard Heathfield <http://www.cpax.org.uk>
> Email: -http://www. +rjh@
> "Usenet is a strange place" - dmr 29 July 1999
> Sig line vacant - apply within
== 3 of 4 ==
Date: Sun, Jan 10 2010 12:21 am
From: Richard Heathfield
spinoza1111 wrote:
<snip>
> He didn't want to explain "my" 1990 rule (parenthesize formal
> parameters in macro definitions, decide whether to return an
> expression or a statement, return nothing else, if you return an
> expression return it in its own set of round parentheses, if you
> return a statement return the statement list in its own set of braces)
> because there might have been counter-examples and the rule is rather
> complicated.
There is no sensible rule, simple or complicated, about what macros
return, because macros don't return anything. We covered this already.
> To be able to understand it, the programmer has to know the difference
> between a formal and an actual parameter and Herb could not assume
> this knowledge in his readers.
He could have explained the difference, and then assumed it. In fact, I
haven't checked - he may well have explained it. Do you know he didn't?
<nonsense snipped>
> Pray, what is gets() replaced with?
There's no need to supply a replacement, since nobody in their right
mind has used it since 1988 or so - unless they have been misguided by
poor texts, and then only until the point when they realise just how
dangerous poor texts can be.
<nonsense snipped>
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
"Usenet is a strange place" - dmr 29 July 1999
Sig line vacant - apply within
== 4 of 4 ==
Date: Sun, Jan 10 2010 12:23 am
From: Richard Heathfield
spinoza1111 wrote:
> On Jan 9, 11:46 pm, Richard Heathfield <r...@see.sig.invalid> wrote:
>> spinoza1111wrote:
>>> On Jan 9, 5:04 pm, Richard Heathfield <r...@see.sig.invalid> wrote:
>>>> spinoza1111wrote:
>>>>> On Jan 9, 10:33 am, Ben Bacarisse <ben.use...@bsb.me.uk> wrote:
>>>> <snip>
>>>>>> I think you've missed the point. The parentheses around (a) are not
>>>>>> the issue because they are, of course, correct. The problem is the
>>>>>> lack of parentheses around the conditional expression.
>>>>> Correctomundo: the conditional expression violates "my" rule, which I
>>>>> developed in 1990, that "each macro that intends to return an
>>>>> EXPRESSION must return an EXPRESSION surrounded by PARENTHESES: each
>>>>> macro that intends to return a STATEMENT must return a STATEMENT LIST
>>>>> surrounded by BRACES".
>>>> Macros don't return either expressions or statements.
>>> Then you misunderstand their proper use despite your "expertise" in C.
>> It's possible, but I don't think it very likely.
>>
>>> If a macro returns anything else besides an expression or statement it
>>> can cause errors.
>> Macros don't return expressions, statements, or *anything else*.
>
> Yes they do. When they are evaluated, they return a fully substituted
> string.
I disagree. Please provide evidence from the Standard to support your
assertion. (You can't, because you're wrong. But feel free to try.)
> You really need to learn the relationship between the ways
> functions are evaluated at run time and macros are evaluated at
> preprocessor time because the similarities and differences are
> fundamental computer science.
Macros are not evaluated at preprocessor time. Macros are expanded at
preprocessor time. Evaluation happens at runtime.
<snip>
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
"Usenet is a strange place" - dmr 29 July 1999
Sig line vacant - apply within
==============================================================================
TOPIC: need the solution
http://groups.google.com/group/comp.lang.c/t/40d72da494945b01?hl=en
==============================================================================
== 1 of 2 ==
Date: Sat, Jan 9 2010 11:26 pm
From: wahid
• In mathematics, the Fibonacci numbers are
the numbers in the following sequence:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144....
• By definition, the first two Fibonacci numbers
are 0 and 1, and each remaining number is the
sum of the previous two. Some sources omit
the initial 0, instead beginning the sequence
with two 1s.
• Write a program using recursion, that will
input an integer value n, and generate the first
n fibonacci numbers.
== 2 of 2 ==
Date: Sun, Jan 10 2010 12:11 am
From: Seebs
On 2010-01-10, wahid <wahid.1144@gmail.com> wrote:
> ? In mathematics, the Fibonacci numbers are
> the numbers in the following sequence:
> 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144....
> ? By definition, the first two Fibonacci numbers
> are 0 and 1, and each remaining number is the
> sum of the previous two. Some sources omit
> the initial 0, instead beginning the sequence
> with two 1s.
>
> ? Write a program using recursion, that will
> input an integer value n, and generate the first
> n fibonacci numbers.
Come on, dude, do your own homework or at least post messages thanking
the people who take the time to contribute suggestions.
-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
==============================================================================
TOPIC: problem
http://groups.google.com/group/comp.lang.c/t/e2f69c6c3d571020?hl=en
==============================================================================
== 1 of 4 ==
Date: Sat, Jan 9 2010 11:29 pm
From: wahid
I m in a problem, i need those solution i will never disturb u people
again ok but send me those .
== 2 of 4 ==
Date: Sat, Jan 9 2010 11:43 pm
From: Francis Glassborow
wahid wrote:
> I m in a problem, i need those solution i will never disturb u people
> again ok but send me those .
If you use any solution given here you really will be stupid. The
regulars here are masters of writing programs for homework questions
that are either riddled with errors or use such contorted C that no
teacher is going to believe they are your work.
If you cannot do any of the problems you have posted then you need to
talk with your teacher because it is only going to get harder from now
on. If you cannot do the basics you have already failed even if you do
not know it yet.
== 3 of 4 ==
Date: Sun, Jan 10 2010 12:15 am
From: Beej Jorgensen
On 01/09/2010 11:29 PM, wahid wrote:
> I m in a problem, i need those solution i will never disturb u people
> again ok but send me those .
Out of curiosity, would you tell us why you need these answers so badly?
These are really basic questions; if they're a prerequisite for
something, you're going to be screwed later no matter what kind of help
you get from this group.
-Beej
== 4 of 4 ==
Date: Sun, Jan 10 2010 12:12 am
From: Seebs
On 2010-01-10, Francis Glassborow <francis.glassborow@btinternet.com> wrote:
> wahid wrote:
>> I m in a problem, i need those solution i will never disturb u people
>> again ok but send me those .
>
> If you use any solution given here you really will be stupid. The
> regulars here are masters of writing programs for homework questions
> that are either riddled with errors or use such contorted C that no
> teacher is going to believe they are your work.
>
> If you cannot do any of the problems you have posted then you need to
> talk with your teacher because it is only going to get harder from now
> on. If you cannot do the basics you have already failed even if you do
> not know it yet.
Francis is, of course, correct. When I write answers to homework
problems, they are such that they would make excellent study projects to
learn interesting things about C, but horrible things to hand in to a
teacher.
-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
==============================================================================
TOPIC: arithmetic on a void * pointer
http://groups.google.com/group/comp.lang.c/t/451b17d19dcc5236?hl=en
==============================================================================
== 1 of 1 ==
Date: Sat, Jan 9 2010 11:31 pm
From: Nobody
On Fri, 08 Jan 2010 19:58:19 -0800, Mark Adler wrote:
>> buf = (int *)buf + n;
>> or
>> buf = (struct foo *)buf + n;
>
> I don't see why we should have to lose the += operator in this case.
This isn't portable (see below), but it's not an error:
*(struct foo **)&buf += n;
> (struct foo *)buf += n looks to me like it should make perfect sense to
> the compiler.
So how should the compiler interpret:
int x;
(float)x = 7.0;
If you can see the problem with that, consider what happens when a void*
uses a different representation to a "struct foo *" (this is why the above
alternative isn't portable).
Assignment only makes sense for lvalues, casts only make sense for
expressions.
==============================================================================
TOPIC: a gift for the mortensens
http://groups.google.com/group/comp.lang.c/t/1911197d173cd869?hl=en
==============================================================================
== 1 of 1 ==
Date: Sat, Jan 9 2010 11:35 pm
From: frank
Christmas persists for me. If you ever get an opportunity to attend a
"white elephant party," do so, because it's hilarious.
My friend Alan Mortensen forbade me from spending money on gifts as I
visited his and my family in Salt lake over the actual holidays, so I'm
working out a way where I can give his girls something of value.
I intend to write a couple C utilities for them, as software is not
dough. Where I'm stuck right now is that I can't seem to find source
for invoking pseudo-random behaviour. So here's my first attempt:
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
void srand(unsigned seed);
int rand(void);
time_t time(something);
srand(time(&timer));
return("pretty pathetic");
}
I've written hundreds of programs in C that invoke pseudo-random
behavior but nothing recently, or as "frank."
So, I'm looking for a link or some tips on how to invoke pseudo-random
behavior in C. Thanks for your comment.
--
frank
==============================================================================
You received this message because you are subscribed to the Google Groups "comp.lang.c"
group.
To post to this group, visit http://groups.google.com/group/comp.lang.c?hl=en
To unsubscribe from this group, send email to comp.lang.c+unsubscribe@googlegroups.com
To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.c/subscribe?hl=en
To report abuse, send email explaining the problem to abuse@googlegroups.com
==============================================================================
Google Groups: http://groups.google.com/?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home