 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Leon Brodskiy Guest
|
Posted: Thu Mar 03, 2005 12:53 pm Post subject: variable usage |
|
|
Hi,
Could you please clarify why the code below doesn't give a compilation
error in line 4? It seem that compiler just skips that line... What a rule
is for such cases?
Thanks a lot.
line 1 void main()
line 2 {
line 3 char *ptr = " Cisco Systems";
line 4 ptr;
line 5 printf("%sn",ptr);
line6 }
--
comp.lang.c.moderated - moderation address: [email]clcm (AT) plethora (DOT) net[/email] -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
|
|
| Back to top |
|
 |
Brian Inglis Guest
|
Posted: Thu Mar 03, 2005 7:48 pm Post subject: Re: variable usage |
|
|
fOn Thu, 3 Mar 2005 12:53:18 -0000 in comp.lang.c.moderated, "Leon
Brodskiy" <ivan (AT) rogers (DOT) com> wrote:
| Quote: | Hi,
Could you please clarify why the code below doesn't give a compilation
error in line 4? It seem that compiler just skips that line... What a rule
is for such cases?
Thanks a lot.
line 1 void main()
line 2 {
line 3 char *ptr = " Cisco Systems";
line 4 ptr;
|
Roughly speaking (not using standard terms/syntax):
ptr -> pp-token -> ident -> var -> term -> expr ; -> stmt
Unlike most languages, any expression can be a statement.
| Quote: | line 5 printf("%sn",ptr);
line 6 }
|
--
Thanks. Take care, Brian Inglis Calgary, Alberta, Canada
[email]Brian.Inglis (AT) CSi (DOT) com[/email] (Brian[dot]Inglis{at}SystematicSW[dot]ab[dot]ca)
fake address use address above to reply
--
comp.lang.c.moderated - moderation address: [email]clcm (AT) plethora (DOT) net[/email] -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
|
|
| Back to top |
|
 |
CBFalconer Guest
|
Posted: Thu Mar 03, 2005 7:48 pm Post subject: Re: variable usage |
|
|
Leon Brodskiy wrote:
| Quote: |
Could you please clarify why the code below doesn't give a
compilation error in line 4? It seem that compiler just skips
that line... What a rule is for such cases?
line 1 void main()
line 2 {
line 3 char *ptr = " Cisco Systems";
line 4 ptr;
line 5 printf("%sn",ptr);
line6 }
|
Why should it? It is just an expression whose value is being
discarded, which also applies to line 5, where the value of
printf(.....) is being discarded. At any rate once you have
written line 1 the behaviour is undefined, because main always
returns an int. You have been reading too much BullSchildt or
Microsoft mis-advice.
--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
--
comp.lang.c.moderated - moderation address: [email]clcm (AT) plethora (DOT) net[/email] -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
|
|
| Back to top |
|
 |
Hans-Bernhard Broeker Guest
|
Posted: Thu Mar 03, 2005 7:48 pm Post subject: Re: variable usage |
|
|
Leon Brodskiy <ivan (AT) rogers (DOT) com> wrote:
| Quote: | Could you please clarify why the code below doesn't give a
compilation error in line 4?
|
Because there's nothing wrong with it. It's a statement with no
effect, but that's not forbidden by any applicable rule.
| Quote: | line 1 void main()
|
If your compiler accepted this line without issuing a warning message,
you're not running it with suitable options.
--
Hans-Bernhard Broeker (broeker (AT) physik (DOT) rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
--
comp.lang.c.moderated - moderation address: [email]clcm (AT) plethora (DOT) net[/email] -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
|
|
| Back to top |
|
 |
WillerZ Guest
|
Posted: Thu Mar 03, 2005 7:49 pm Post subject: Re: variable usage |
|
|
Leon Brodskiy wrote:
| Quote: | Hi,
Could you please clarify why the code below doesn't give a compilation
error in line 4? It seem that compiler just skips that line... What a rule
is for such cases?
|
Check sections 6.8.3 and 6.5.1. That line is a valid expression
statement. Expression statements are evaluated for their side-effects,
but in this case it's quite likely that your compiler has noticed that
there are no side-effects and has optimised it away.
You may be able to get your compiler to emit a diagnostic message when
this happens (I think it's -Wunused-value on gcc).
Hope this helps.
--
comp.lang.c.moderated - moderation address: [email]clcm (AT) plethora (DOT) net[/email] -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
|
|
| Back to top |
|
 |
Clark S. Cox III Guest
|
Posted: Thu Mar 03, 2005 7:49 pm Post subject: Re: variable usage |
|
|
On 2005-03-03 07:53:18 -0500, "Leon Brodskiy" <ivan (AT) rogers (DOT) com> said:
| Quote: | Hi,
Could you please clarify why the code below doesn't give a compilation
error in line 4? It seem that compiler just skips that line... What a rule
is for such cases?
Thanks a lot.
|
First, you forgot to include <stdio.h>
Second, main() returns an int.
| Quote: | void main()
{
char *ptr = " Cisco Systems";
|
The following line is not a problem. ptr is simply an expression.
Though, as you noted, it's value is ignored.
If you think about it, it is quit similar to what happens in the
following line. printf is a function that returns an int. You ignore
that value here as well. There's nothing wrong with that either.
| Quote: | printf("%sn",ptr);
|
You forgot to return 0 here (assuming that you're not using a C99 compiler)
--
Clark S. Cox, III
[email]clarkcox3 (AT) gmail (DOT) com[/email]
--
comp.lang.c.moderated - moderation address: [email]clcm (AT) plethora (DOT) net[/email] -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
|
|
| Back to top |
|
 |
Dave Neary Guest
|
Posted: Thu Mar 03, 2005 7:49 pm Post subject: Re: variable usage |
|
|
Hi,
On Thu, 3 Mar 2005 12:53:18 -0000, Leon Brodskiy said:
| Quote: | line 1 void main()
|
There are a few things that you should have tried to pick up
before posting here... the first of these is "main returns int".
| Quote: | line 2 {
line 3 char *ptr = " Cisco Systems";
line 4 ptr;
|
Why would you expect an error? This is a valid expression, which
evaluates the variable ptr and discards the value.
| Quote: | line 5 printf("%sn",ptr);
|
Since printf is a variadic function, it requires a prototype.
Thus, you forgot to include line 0,
#include <stdio.h>
the the code you posted.
Cheers,
Dave.
--
David Neary,
E-Mail: bolsh at gimp dot org
CV: http://dneary.free.fr/CV/
--
comp.lang.c.moderated - moderation address: [email]clcm (AT) plethora (DOT) net[/email] -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
|
|
| Back to top |
|
 |
Gordon Burditt Guest
|
Posted: Thu Mar 03, 2005 7:49 pm Post subject: Re: variable usage |
|
|
| Quote: | Could you please clarify why the code below doesn't give a compilation
error in line 4? It seem that compiler just skips that line... What a rule
is for such cases?
Thanks a lot.
line 1 void main()
|
You *SHOULD* get a compilation error for line 1.
| Quote: |
line 2 {
line 3 char *ptr = " Cisco Systems";
line 4 ptr;
|
Line 4 is a perfectly valid expression (even though it doesn't do anything useful).
So, for example, is:
52;
or
2+2;
| Quote: |
line 5 printf("%sn",ptr);
line6 }
--
comp.lang.c.moderated - moderation address: [email]clcm (AT) plethora (DOT) net[/email] -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
|
` ` Gordon L. Burditt
--
comp.lang.c.moderated - moderation address: [email]clcm (AT) plethora (DOT) net[/email] -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
|
|
| Back to top |
|
 |
CBFalconer Guest
|
Posted: Sat Mar 26, 2005 11:22 pm Post subject: Re: variable usage |
|
|
you're fighting for.
I'm not a politician, not even a student of politics; in fact, I'm not a
student of much of anything. I'm not a Democrat. I'm not a Republican,
and I don't even consider myself an American. If you and I were
Americans, there'd be no problem. Those Honkies that just got off the
boat, they're already Americans; Polacks are already Americans; the
Italian refugees are already Americans. Everything that came out of
Europe, every blue-eyed thing, is already an American. And as long as
you and I have been over here, we aren't Americans yet.
Well, I am one who doesn't believe in deluding myself. I'm not going to
sit at your table and watch you eat, with nothing on my plate, and call
myself a diner. Sitting at the table doesn't make you a diner, unless
you eat some of what's on that plate. Being here in America doesn't make
you an American. Being born here in America doesn't make you an
American. Why, if birth made you American, you wouldn't need any
legislation; you wouldn't need any amendments to the Constitution; you
wouldn't be faced with civil-rights filibustering in Washington, D.C.,
right now. They don't have to pass civil-rights legislation to make a
Polack an American.
No, I'm not an American. I'm one of the 22 million black people who are
the victims of Americanism. One of the 22 million black people who are
the victims of democracy, nothing but disguised hypocrisy. So, I'm not
standing here speaking to you as an American, or a patriot, or a
flag-saluter, or a flag-waver -- no, not I. I'm speaking as a victim of
this American system. And I see America through the eyes of the victim.
I don't see any American dream; I see an American nightmare.
These 22 million victims are waking up. Their eyes are coming open.
They're beginning to see what they used to only look at. They're
becoming politically mature. They ar
|
|
| Back to top |
|
 |
Hans-Bernhard Broeker Guest
|
Posted: Sat Mar 26, 2005 11:23 pm Post subject: Re: variable usage |
|
|
from Angola and
was being colonized by the Portuguese. When they came to the Bandung
conference, they looked at the Portuguese, and at the Frenchman, and at
the Englishman, and at the other -- Dutchman -- and learned or realized
that the one thing that all of them had in common: they were all from
Europe, they were all Europeans, blond, blue-eyed and white-skinned.
They began to recognize who their enemy was. The same man that was
colonizing our people in Kenya was colonizing our people in the Congo.
The same one in the Congo was colonizing our people in South Africa, and
in Southern Rhodesia, and in Burma, and in India, and in Afghanistan,
and in Pakistan. They realized all over the world where the dark man was
being oppressed, he was being oppressed by the white man; where the dark
man was being exploited, he was being exploited by the white man. So
they got together under this basis -- that they had a common enemy.
And when you and I here in Detroit and in Michigan and in America who
have been awakened today look around us, we too realize here in America
we all have a common enemy, whether he's in Georgia or Michigan, whether
he's in California or New York. He's the same man: blue eyes and blond
hair and pale skin -- same man. So what we have to do is what they did.
They agreed to stop quarreling among themselves. Any little spat that
they had, they'd settle it among themselves, go into a huddle -- don't
let the enemy know that you got [sic] a disagreement.
Instead of us airing our differences in public, we have to realize we're
all the same family. And when you have a family squabble, you don't get
out on the sidewalk. If you do, everybody calls you uncout
|
|
| Back to top |
|
 |
WillerZ Guest
|
Posted: Sat Mar 26, 2005 11:23 pm Post subject: Re: variable usage |
|
|
and the politicians in his own community; no
more. The black man in the black community has to be re-educated into
the science of politics so he will know what politics is supposed to
bring him in return. Don't be throwing out any ballots. A ballot is like
a bullet. You don't throw your ballots until you see a target, and if
that target is not within your reach, keep your ballot in your pocket.
The political philosophy of black nationalism is being taught in the
Christian church. It's being taught in the NAACP. It's being taught in
CORE meetings. It's being taught in SNCC Student Nonviolent Coordinating
Committee meetings. It's being taught in Muslim meetings. It's being
taught where nothing but atheists and agnostics come together. It's
being taught everywhere. Black people are fed up with the dillydallying,
pussyfooting, compromising approach that we've been using toward getting
our freedom. We want freedom now, but we're not going to get it saying
"We Shall Overcome." We've got to fight until we overcome.
The economic philosophy of black nationalism is pure and simple. It only
means that we should control the economy of our community. Why should
white people be running all the stores in our community? Why should
white people be running the banks of our community? Why should the
economy of our community be in the hands of the white man? Why? If a
black man can't move his store into a white community, you tell me why a
white man should move his store into a black community. The philosophy
of black nationalism involves a re-education program in the black
community in regards to economics. Our people have to be made to see
that a
|
|
| Back to top |
|
 |
Clark S. Cox III Guest
|
Posted: Sat Mar 26, 2005 11:23 pm Post subject: Re: variable usage |
|
|
Nothing but a circus, with clowns and all. You had one right
here in Detroit -- I saw it on television -- with clowns leading it,
white clowns and black clowns. I know you don't like what I'm saying,
but I'm going to tell you anyway. 'Cause I can prove what I'm saying. If
you think I'm telling you wrong, you bring me Martin Luther King and A.
Philip Randolph and James Farmer and those other three, and see if
they'll deny it over a microphone.
No, it was a sellout. It was a takeover. When James Baldwin came in from
Paris, they wouldn't let him talk, 'cause they couldn't make him go by
the script. Burt Lancaster read the speech that Baldwin was supposed to
make; they wouldn't let Baldwin get up there, 'cause they know Baldwin's
liable to say anything. They controlled it so tight -- they told those
Negroes what time to hit town, how to come, where to stop, what signs to
carry, *what song to sing*, what speech they could make, and what speech
they couldn't make; and then told them to get out town by sundown. And
everyone of those Toms was out of town by sundown. Now I know you don't
like my saying this. But I can back it up. It was a circus, a
performance that beat anything Hollywood could ever do, the performance
of the year. Reuther and those other three devils should get a Academy
Award for the best actors 'cause they acted like they really loved
Negroes and fooled a whole lot of Negroes. And the six Negro leaders
should get an award too, for the best supporting cast.
==========================================================================
Mr. Moderator, Brother Lomax, brothers and sisters, friends and enemies:
I just can't believe everyone in here is a fri
|
|
| Back to top |
|
 |
Dave Neary Guest
|
Posted: Sat Mar 26, 2005 11:23 pm Post subject: Re: variable usage |
|
|
out town by sundown. And
everyone of those Toms was out of town by sundown. Now I know you don't
like my saying this. But I can back it up. It was a circus, a
performance that beat anything Hollywood could ever do, the performance
of the year. Reuther and those other three devils should get a Academy
Award for the best actors 'cause they acted like they really loved
Negroes and fooled a whole lot of Negroes. And the six Negro leaders
should get an award too, for the best supporting cast.
==========================================================================
Mr. Moderator, Brother Lomax, brothers and sisters, friends and enemies:
I just can't believe everyone in here is a friend, and I don't want to
leave anybody out. The question tonight, as I understand it, is "The
Negro Revolt, and Where Do We Go From Here?" or What Next?" In my little
humble way of understanding it, it points toward either the ballot or
the bullet.
Before we try and explain what is meant by the ballot or the bullet, I
would like to clarify something concerning myself. I'm still a Muslim;
my religion is still Islam. That's my personal belief. Just as Adam
Clayton Powell is a Christian minister who heads the Abyssinian Baptist
Church in New York, but at the same time takes part in the political
struggles to try and bring about rights to the black people in this
country; and Dr. Martin Luther King is a Christian minister down in
Atlanta, Georgia, who heads another organization fighting for the civil
rights of black people in this country; and Reverend Galamison, I guess
you've heard of him, is another Christian minister in New York who
|
|
| Back to top |
|
 |
Gordon Burditt Guest
|
Posted: Sat Mar 26, 2005 11:23 pm Post subject: Re: variable usage |
|
|
with
that kind of conspiracy, let them know your eyes are open. And let them
know you -- something else that's wide open too. It's got to be the
ballot or the bullet. The ballot or the bullet. If you're afraid to use
an expression like that, you should get on out of the country; you
should get back in the cotton patch; you should get back in the alley.
They get all the Negro vote, and after they get it, the Negro gets
nothing in return. All they did when they got to Washington was give a
few big Negroes big jobs. Those big Negroes didn't need big jobs, they
already had jobs. That's camouflage, that's trickery, that's treachery,
window-dressing. I'm not trying to knock out the Democrats for the
Republicans. We'll get to them in a minute. But it is true; you put the
Democrats first and the Democrats put you last.
Look at it the way it is. What alibis do they use, since they control
Congress and the Senate? What alibi do they use when you and I ask,
"Well, when are you going to keep your promise?" They blame the
Dixiecrats. What is a Dixiecrat? A Democrat. A Dixiecrat is nothing but
a Democrat in disguise. The titular head of the Democrats is also the
head of the Dixiecrats, because the Dixiecrats are a part of the
Democratic Party. The Democrats have never kicked the Dixiecrats out of
the party. The Dixiecrats bolted themselves once, but the Democrats
didn't put them out. Imagine, these lowdown Southern
|
|
| Back to top |
|
 |
Gordon Burditt Guest
|
Posted: Wed Mar 30, 2005 12:14 am Post subject: Re: variable usage |
|
|
1 batch cornbread stuffing (see index)
½ cup melted butter
Remove the giblets from the infant and set aside.
Stuff the cavity where the child?s genitals and anus were located
using ½ cup per pound of meat.
Tie the arms flat to the body, then pull the skin flaps up to close the cavity.
Now tie the thighs up tight to hold it all together.
Place breast side up in a large metal roasting pan.
Bake in 325° oven covered for 2 hours.
Remove cover, stick a cooking thermometer deep into one of the
baby?s buttocks and cook uncovered till thermometer reads 190°,
about another hour.
Pro-Choice Po-Boy
Soft-shelled crabs serve just as well in this classic southern delicacy.
The sandwich originated in New Orleans, where an abundance of abortion clinics
thrive and hot French bread is always available.
2 cleaned fetuses, head on
2 eggs
1 tablespoon yellow mustard
1 cup seasoned flour
oil enough for deep frying
1 loaf French bread
Lettuce
tomatoes
mayonnaise, etc.
Marinate the fetuses in the egg-mustard mixture.
Dredge thoroughly in flour.
Fry at 375° until crispy golden brown.
Remove and place on paper towels.
Holiday Youngster
One can easily adapt this recipe to ham, though as presented,
it violates no religious taboos against swine.
1 large toddler or small child, cleaned and de-headed
Kentucky Bourbon Sauce (see index)
1 large can pineapple slices
Whole cloves
Place him (or ham) or her in a large glass baking dish, buttocks up.
Tie with butcher string around a
|
|
| Back to top |
|
 |
Powered by phpBB © 2001, 2006 phpBB Group
|