By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,686 Members | 2,392 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,686 IT Pros & Developers. It's quick & easy.

Accessing a global variable when there is a local variable in the same name

P: n/a
int i = 10;
int main()
{
int i = 20;
return 0;
}

Hi All,

I want to access the global variable i inside the main. Is there
a way to do this in C?

Regards,
Mohan.
Nov 14 '05 #1
Share this Question
Share on Google+
44 Replies


P: n/a
Mohanasundaram wrote:
int i = 10;
int main()
{
int i = 20;
return 0;
}

Hi All,

I want to access the global variable i inside the main. Is there
a way to do this in C?


By not masking it with a redeclaration inside main.
Nov 14 '05 #2

P: n/a
On 2004-06-25, Mohanasundaram <mo************@msn.com> wrote:
int i = 10;
int main()
{
int i = 20;
return 0;
}

I want to access the global variable i inside the main. Is there
a way to do this in C?


int i = 10;
int main(void)
{
int *global_i_pointer = &i;
int i = 20;

/* ... use global_i_pointer to access the global variable i
from inside main ... */

return 0;
}

-- James
Nov 14 '05 #3

P: n/a
Mohanasundaram wrote:
int i = 10;
int main()
{
int i = 20;
return 0;
}

Hi All,

I want to access the global variable i inside the main. Is there
a way to do this in C?


There's the easy way and the smartarse way.

The easy way is to rename the local i to something else, or to rename
the global i to something more sensible (a global variable called "i"
is probably a very bad idea).

The smararse way involves using pointers or nested extern declarations.
I'm not going to tell you the details. Just rename one or both i's.

--
Chris "electric hedgehog" Dollin
C FAQs at: http://www.faqs.org/faqs/by-newsgrou...mp.lang.c.html
C welcome: http://www.angelfire.com/ms3/bchambl...me_to_clc.html
Nov 14 '05 #4

P: n/a

"Mohanasundaram" <mo************@msn.com> wrote in message news:9b*************************@posting.google.co m...
int i = 10;
int main()
{
int i = 20;
return 0;
}

Hi All,

I want to access the global variable i inside the main. Is there
a way to do this in C?

Regards,
Mohan.


int i = 10;
int main(void)
{
int i = 5;
{
extern int i;
i; /* the expression i will evaluate to 10 */
}
return 0;
}

--
Vijay Kumar R Zanvar
My Home Page - http://www.geocities.com/vijoeyz/
Nov 14 '05 #5

P: n/a
Chris Dollin wrote:
Mohanasundaram wrote:
int i = 10;
int main()
{
int i = 20;
return 0;
}

I want to access the global variable i inside the main. Is there
a way to do this in C?


There's the easy way and the smartarse way.

.... snip ...

Around here, for a question like this, only the smartarse way is
acceptable.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!

Nov 14 '05 #6

P: n/a
In <9b*************************@posting.google.com> mo************@msn.com (Mohanasundaram) writes:
int i = 10;
int main()
{
int i = 20;
return 0;
}

Hi All,

I want to access the global variable i inside the main. Is there
a way to do this in C?


Explain why you can't rename one of the two variables.

If this is a homework question, try finding a better instructor. This
issue should NEVER arise in real C programs.

#include <stdio.h>

int i = 10;

int main()
{
int j = i;
int i = 20;
printf("%d\n", j);
return 0;
}

If the value of the global i might change during the execution of main(),
replace the definition of j by

int *p = &i;

but keep it still *before* the definition of the local i, and use *p any
time you need to access the global i.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #7

P: n/a
CBFalconer <cb********@yahoo.com> writes:
Chris Dollin wrote:
Mohanasundaram wrote:
int i = 10;
int main()
{
int i = 20;
return 0;
}

I want to access the global variable i inside the main. Is there
a way to do this in C?


There's the easy way and the smartarse way.

... snip ...

Around here, for a question like this, only the smartarse way is
acceptable.


The obvious way, as others have mentioned, is to change the name of
the local variable. (Some languages have ways to refer directly to
variables in outer scopes using expanded names; C doesn't. I suspect
that's what the OP was really asking about.)

But the smartarse way, using a pointer, does illustrate what might
sometimes be a relevant point: just because a function doesn't have
direct visibility to a variable (either because it's hidden by a
declaration in an inner scope, or because it's a static variable
declared in another file or function), you can't necessarily assume
that the function can't read or modify the variable.

--
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.
Nov 14 '05 #8

P: n/a
In 'comp.lang.c', James Hu <jx*@despammed.com> wrote:
int i = 10;
int main()
{
int i = 20;
return 0;
}

I want to access the global variable i inside the main. Is there
a way to do this in C?


int i = 10;
int main(void)
{
int *global_i_pointer = &i;
int i = 20;

/* ... use global_i_pointer to access the global variable i
from inside main ... */

return 0;
}


Clever. I'll try to keep it in mind.

--
-ed- get my email here: http://marreduspam.com/ad672570
The C-language FAQ: http://www.eskimo.com/~scs/C-faq/top.html
C-reference: http://www.dinkumware.com/manuals/reader.aspx?lib=c99
FAQ de f.c.l.c : http://www.isty-info.uvsq.fr/~rumeau/fclc/
Nov 14 '05 #9

P: n/a
Da*****@cern.ch (Dan Pop) writes:
In <9b*************************@posting.google.com>
mo************@msn.com (Mohanasundaram) writes:
int i = 10;
int main()
{
int i = 20;
return 0;
}

Hi All,

I want to access the global variable i inside the main. Is there
a way to do this in C?


Explain why you can't rename one of the two variables.

If this is a homework question, try finding a better instructor. This
issue should NEVER arise in real C programs.

#include <stdio.h>

int i = 10;

int main()
{
int j = i;
int i = 20;
printf("%d\n", j);
return 0;
}

If the value of the global i might change during the execution of main(),
replace the definition of j by

int *p = &i;

but keep it still *before* the definition of the local i, and use *p any
time you need to access the global i.


Yes, that will work. It will also create a potential headache for
future maintainers. Code that silently changes behavior when the
order of declarations is changed is not generally a good idea.

--
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.
Nov 14 '05 #10

P: n/a
In <ln************@nuthaus.mib.org> Keith Thompson <ks***@mib.org> writes:
Da*****@cern.ch (Dan Pop) writes:
In <9b*************************@posting.google.com>
mo************@msn.com (Mohanasundaram) writes:
>int i = 10;
>int main()
>{
> int i = 20;
> return 0;
>}
>
>Hi All,
>
> I want to access the global variable i inside the main. Is there
>a way to do this in C?


Explain why you can't rename one of the two variables.

If this is a homework question, try finding a better instructor. This ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ issue should NEVER arise in real C programs. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#include <stdio.h>

int i = 10;

int main()
{
int j = i;
int i = 20;
printf("%d\n", j);
return 0;
}

If the value of the global i might change during the execution of main(),
replace the definition of j by

int *p = &i;

but keep it still *before* the definition of the local i, and use *p any
time you need to access the global i.


Yes, that will work. It will also create a potential headache for
future maintainers. Code that silently changes behavior when the
order of declarations is changed is not generally a good idea.


Which part of "This issue should NEVER arise in real C programs." was too
difficult for you to understand?

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #11

P: n/a
Da*****@cern.ch (Dan Pop) writes:
In <ln************@nuthaus.mib.org> Keith Thompson <ks***@mib.org> writes:
Da*****@cern.ch (Dan Pop) writes:
In <9b*************************@posting.google.com>
mo************@msn.com (Mohanasundaram) writes:
>int i = 10;
>int main()
>{
> int i = 20;
> return 0;
>}
>
>Hi All,
>
> I want to access the global variable i inside the main. Is there
>a way to do this in C?

Explain why you can't rename one of the two variables.

If this is a homework question, try finding a better instructor. This ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ issue should NEVER arise in real C programs. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#include <stdio.h>

int i = 10;

int main()
{
int j = i;
int i = 20;
printf("%d\n", j);
return 0;
}

If the value of the global i might change during the execution of main(),
replace the definition of j by

int *p = &i;

but keep it still *before* the definition of the local i, and use *p any
time you need to access the global i.


Yes, that will work. It will also create a potential headache for
future maintainers. Code that silently changes behavior when the
order of declarations is changed is not generally a good idea.


Which part of "This issue should NEVER arise in real C programs." was too
difficult for you to understand?


I understood it quite well, and I agree with it.

You declared that "This issue should NEVER arise in real C programs."
You could have stopped there, but you chose to present a solution.
That's fine. I commented on your solution. I agreed that it would
work, and raised another point that supports your contention that
"This issue should NEVER arise in real C programs."

--
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.
Nov 14 '05 #12

P: n/a
In <ln************@nuthaus.mib.org> Keith Thompson <ks***@mib.org> writes:
Da*****@cern.ch (Dan Pop) writes:
In <ln************@nuthaus.mib.org> Keith Thompson <ks***@mib.org> writes:
>Da*****@cern.ch (Dan Pop) writes:
>> In <9b*************************@posting.google.com>
>> mo************@msn.com (Mohanasundaram) writes:
>> >int i = 10;
>> >int main()
>> >{
>> > int i = 20;
>> > return 0;
>> >}
>> >
>> >Hi All,
>> >
>> > I want to access the global variable i inside the main. Is there
>> >a way to do this in C?
>>
>> Explain why you can't rename one of the two variables.
>>
>> If this is a homework question, try finding a better instructor. This

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^
>> issue should NEVER arise in real C programs.

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>
>> #include <stdio.h>
>>
>> int i = 10;
>>
>> int main()
>> {
>> int j = i;
>> int i = 20;
>> printf("%d\n", j);
>> return 0;
>> }
>>
>> If the value of the global i might change during the execution of main(),
>> replace the definition of j by
>>
>> int *p = &i;
>>
>> but keep it still *before* the definition of the local i, and use *p any
>> time you need to access the global i.
>
>Yes, that will work. It will also create a potential headache for
>future maintainers. Code that silently changes behavior when the
>order of declarations is changed is not generally a good idea.


Which part of "This issue should NEVER arise in real C programs." was too
difficult for you to understand?


I understood it quite well, and I agree with it.

You declared that "This issue should NEVER arise in real C programs."
You could have stopped there, but you chose to present a solution.


A solution to a *homework question*, which you arbitrarily chose to treat
as advice about how to write real C programs, otherwise your comment about
future maintainers would be downright idiotic: homework answers have no
future maintainers.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #13

P: n/a
Da*****@cern.ch (Dan Pop) writes:
In <ln************@nuthaus.mib.org> Keith Thompson <ks***@mib.org> writes:

[snip]
I understood it quite well, and I agree with it.

You declared that "This issue should NEVER arise in real C programs."
You could have stopped there, but you chose to present a solution.


A solution to a *homework question*, which you arbitrarily chose to treat
as advice about how to write real C programs, otherwise your comment about
future maintainers would be downright idiotic: homework answers have no
future maintainers.


Who said it was a homework question? The OP didn't say so. It's
entirely possible that it was homework; it's also possible that the OP
was trying to find out whether C has some kind of scope resolution
mechanism, as some other languages do.

I didn't treat your solution as advice about how to write real C
programs, but others might. In any case, I was simply expanding on
what you wrote. I don't know why you have a problem with that.

--
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.
Nov 14 '05 #14

P: n/a
In <ln************@nuthaus.mib.org> Keith Thompson <ks***@mib.org> writes:
Da*****@cern.ch (Dan Pop) writes:
In <ln************@nuthaus.mib.org> Keith Thompson <ks***@mib.org> writes:[snip]
>I understood it quite well, and I agree with it.
>
>You declared that "This issue should NEVER arise in real C programs."
>You could have stopped there, but you chose to present a solution.


A solution to a *homework question*, which you arbitrarily chose to treat
as advice about how to write real C programs, otherwise your comment about
future maintainers would be downright idiotic: homework answers have no
future maintainers.


Who said it was a homework question? The OP didn't say so. It's
entirely possible that it was homework;


My own text, prefacing the actual code, made it crystal clear that it was
supposed to be the answer to a stupid homework question and NOT used in
real life C code:

Explain why you can't rename one of the two variables.

If this is a homework question, try finding a better instructor. This
issue should NEVER arise in real C programs.
it's also possible that the OP
was trying to find out whether C has some kind of scope resolution
mechanism, as some other languages do.
And the answer is that it does (as shown in the various posted examples),
but it's better left unused.
I didn't treat your solution as advice about how to write real C
programs, but others might.
Why? Was my disclaimer clear enough for you, but not for others?
In any case, I was simply expanding on
what you wrote. I don't know why you have a problem with that.


Because I hate idiotic expansions on what I write. As I have already
explained, it makes no sense to invoke the future maintainers of something
that is *explicitly* presented as "not to be done in real C programs".

Without my explicit warning, your expansions would have been perfectly
sensible.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #15

P: n/a
Da*****@cern.ch (Dan Pop) writes:
In <ln************@nuthaus.mib.org> Keith Thompson <ks***@mib.org> writes:

[...]
In any case, I was simply expanding on
what you wrote. I don't know why you have a problem with that.


Because I hate idiotic expansions on what I write.


Dan, it's really not that big a deal. What I wrote may not have been
necessary; your overreaction to it certainly wasn't.

In the future, I will spend less time worrying about your opinion
other than on relevant technical issues. I'll probably continue to do
things that make you angry (because there doesn't seem to be any way
to avoid that other than leaving the newsgroup). You can deal with
that in whatever way you choose.

--
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.
Nov 14 '05 #16

P: n/a
Hi Dan,

This was an interview question. It is not a homework question. I
just wanted to know whether it is possible to do that like what we do
in C++. We use :: operator in C++ to access the global variable. I
wanted to know is there any language support in C to do this. If you
know please share the answer. If not please ......

I though the answer is either
There is no language support in C
or
There is an operator or something similar to do so like ::

Mohan.
Nov 14 '05 #17

P: n/a
Hi Thomson,

I feel you make lot of sense and show maturity in the full
thread. You are right and I wanted to know whether C supports any
thing similar to :: for accesing global varibles in C++. It was not a
homework question. I decided to ask this in this group because I had
and argument with an interviewer.

Regards,
Mohan.
Nov 14 '05 #18

P: n/a
In <9b*************************@posting.google.com> mo************@msn.com (Mohanasundaram) writes:
Hi Dan,

This was an interview question. It is not a homework question. I
just wanted to know whether it is possible to do that like what we do
in C++. We use :: operator in C++ to access the global variable. I
wanted to know is there any language support in C to do this. If you
know please share the answer. If not please ......
Are you a patent idiot or what? I have already provided the answer.
Or are you unable to read standard C code?

There was no mention of the C++ :: operator in your initial question,
was it?
I though the answer is either
There is no language support in C
or
There is an operator or something similar to do so like ::


And you were wrong. There is language support in C, but it doesn't
involve any operator.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #19

P: n/a
Da*****@cern.ch (Dan Pop) writes:
In <9b*************************@posting.google.com>
mo************@msn.com (Mohanasundaram) writes:
Hi Dan,

This was an interview question. It is not a homework question. I
just wanted to know whether it is possible to do that like what we do
in C++. We use :: operator in C++ to access the global variable. I
wanted to know is there any language support in C to do this. If you
know please share the answer. If not please ......


Are you a patent idiot or what? I have already provided the answer.
Or are you unable to read standard C code?

There was no mention of the C++ :: operator in your initial question,
was it?


The intent of Mohanasundaram's original question was to ask whether C
has an operator that provides access to declarations in outer scopes
that are otherwise hidden. (That wasn't entirely clear from his
original question, but it's very clear now that he's come back and
clarified it.) There are such operators in some other languages (C++
and Perl have "::", Ada has ".", and I'm sure there are plenty of
other examples). The question might have been clearer if he had
mentioned C++'s "::" operator, but this is, after all, a C newsgroup.

The underlying question was actually a very good one, regardless of
the fact that the answer happens to be "no". And I'd recommend to
other posters, particularly newbies, that if you see us going off
track in discussing something you've asked about, please jump in early
and clarify what you really meant.
I though the answer is either
There is no language support in C
or
There is an operator or something similar to do so like ::


And you were wrong. There is language support in C, but it doesn't
involve any operator.


The solution Dan Pop provided was not so much a feature of C as a
workaround for the lack of a feature in C. It was a reasonable answer
to the original question as stated, but it didn't answer the intended
question. Yes, as I said, the original question could have been
worded more clearly; it took me a while to figure out the point
myself, and I'm not criticizing Dan for missing it.

I think most of the regulars here have either stopped reading Dan
Pop's postings or have learned to apply a mental "Dan Pop filter",
reading for technical content (which is usually very good) and
ignoring the abuse.

I hope that not too many newbies are put off by Dan Pop's appalling
rudeness, which I expect he'll demonstrate again in response to this
post.

--
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.
Nov 14 '05 #20

P: n/a
You Dan idiot mind your language. I am not asking you to give me the
answer now. I am talking about your original posting. Dont think than
you are the great in the world. Stop being rude and stop using foul
language.
Nov 14 '05 #21

P: n/a
>And I'd recommend to
other posters, particularly newbies, that if you see us going off
track in discussing something you've asked about, please jump in early
and clarify what you really meant.


[Mohan] Hi Thomson, Thanks for your explanation. I should have jumped
in in early stage and should have clarified what I really meant. But I
could not do that because last week i was not well and did not come to
office. But what made me upset was Dan's rudeness. If newbies want to
clarify something which is not easily found in book or want a expert
comment the only place is this group. This is to share our knowledge
and help people learn C. If people like Dan behave like this then new
comers will stamp this group as the one with a bunch or rude people
who call themselves as experts.

Regards,
Mohan.
Nov 14 '05 #22

P: n/a
mo************@msn.com (Mohanasundaram) writes:
And I'd recommend to
other posters, particularly newbies, that if you see us going off
track in discussing something you've asked about, please jump in early
and clarify what you really meant.


[Mohan] Hi Thomson, Thanks for your explanation.


You're welcome.

BTW, my last name is spelled Thompson, but just call me Keith.

--
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.
Nov 14 '05 #23

P: n/a
In <ln************@nuthaus.mib.org> Keith Thompson <ks***@mib.org> writes:
Da*****@cern.ch (Dan Pop) writes:
In <9b*************************@posting.google.com>
mo************@msn.com (Mohanasundaram) writes:
>Hi Dan,
>
> This was an interview question. It is not a homework question. I
>just wanted to know whether it is possible to do that like what we do
>in C++. We use :: operator in C++ to access the global variable. I
>wanted to know is there any language support in C to do this. If you
>know please share the answer. If not please ......
Are you a patent idiot or what? I have already provided the answer.
Or are you unable to read standard C code?

There was no mention of the C++ :: operator in your initial question,
was it?


The intent of Mohanasundaram's original question was to ask whether C
has an operator that provides access to declarations in outer scopes
that are otherwise hidden. (That wasn't entirely clear from his
original question, but it's very clear now that he's come back and
clarified it.)


That was not clear *at all* from his original question:

int i = 10;
int main()
{
int i = 20;
return 0;
}

Hi All,

I want to access the global variable i inside the main. Is there
a way to do this in C?

How can you read "Is there a way to do this in C?" as "Does C provide any
scope resolution operator?" ? Am I English impaired or what? The
questions asks for a solution *without* imposing *anything* on that
solution, as in "Is there an operator for doing that in C?".

The OP's "clarification" is actually a *completely* different question.
And I would answer with another question: why would C need a scope
resolution operator?
There are such operators in some other languages (C++
and Perl have "::", Ada has ".", and I'm sure there are plenty of
other examples).
Languages that *need* such an operator (for one *good* reason or another).
In C, all you have to do to access the "global" variable is not to
reuse its name. Couldn't be simpler than that.
The question might have been clearer if he had
mentioned C++'s "::" operator, but this is, after all, a C newsgroup.
So what? It is current practice to include references to other
programming languages in questions, to make your intent clearer to those
familiar to those languages.
The underlying question was actually a very good one, regardless of
the fact that the answer happens to be "no".


I don't think so, as long as it was about a feature that C doesn't need
in the first place. If you're aware of any *good* use for a scope
resolution operator in C, please elaborate.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #24

P: n/a
Da*****@cern.ch (Dan Pop) writes:
[...]
How can you read "Is there a way to do this in C?" as "Does C provide any
scope resolution operator?" ? Am I English impaired or what? The
questions asks for a solution *without* imposing *anything* on that
solution, as in "Is there an operator for doing that in C?".
I already said that the original question was unclear. I did manage
to figure out the intent before the OP posted his followup; I ascribe
that mostly to luck and to the fact that I spent many years
programming in Ada, a language that does have a scope resolution
mechanism.

I believe that the lack of clarity in the original question was an
innocent oversight, not an indication that the original poster is an
idiot, but I don't care to argue the point.
The OP's "clarification" is actually a *completely* different question.
And I would answer with another question: why would C need a scope
resolution operator?


It probably doesn't. I said that C lacks such a mechanism; I never
said that it needs one.

--
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.
Nov 14 '05 #25

P: n/a
On 2 Jul 2004 01:22:45 -0700, in comp.lang.c , mo************@msn.com
(Mohanasundaram) wrote:
office. But what made me upset was Dan's rudeness.


Don't waste your time and energy being upset about that - Dan has the
social skills of a skunk, and treats everyone that way.

He is however a C expert, and rarely wrong, once you pick your way through
the insults, contempt and overweening self-esteem
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 14 '05 #26

P: n/a
kal
mo************@msn.com (Mohanasundaram) wrote in message news:<9b**************************@posting.google. com>...
You Dan <expletive> mind your language.


Now, now! There is no need for that.

Your original question should have been:
"Is there a scope resolution operator in C?"

The answer is NO. If you think about it (it took me a
while but then I am slow) you will see that there is
no need for such an operator in C.

No inheritance hence no need for scope resolution!

It seems that those who decide upon C specifications are
more apt to apply Occam's razor than not. Which, IMHO,
is just as well.

I suspect that the interviewer was interested not in the
answer itself but rather if you have grasped the concepts
of C++.

<OT>
Your satement, referred to above, is also poorly phrased.
A more indiomatic version would be:
"Mohanasundaram, you <expletive>, mind your tongue!"
</OT>
Nov 14 '05 #27

P: n/a
In <ln************@nuthaus.mib.org> Keith Thompson <ks***@mib.org> writes:
Da*****@cern.ch (Dan Pop) writes:
[...]
How can you read "Is there a way to do this in C?" as "Does C provide any
scope resolution operator?" ? Am I English impaired or what? The
questions asks for a solution *without* imposing *anything* on that
solution, as in "Is there an operator for doing that in C?".
I already said that the original question was unclear.


Wrong, it was crystal-clear. Show me what part of it was phrased in
unclear terms.
I believe that the lack of clarity in the original question was an
innocent oversight,


There was no lack of clarity in the original question, unless you can
point out where exactly it was unclear.

The OP posted a clearly formulated question. It's no one else's
fault that his clearly formulated question did not match his intent.
The OP's "clarification" is actually a *completely* different question.
And I would answer with another question: why would C need a scope
resolution operator?


It probably doesn't. I said that C lacks such a mechanism; I never
said that it needs one.


You *implied* it, when mentioning other languages having it, without
pointing out that C doesn't need have it because there is no need for it.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #28

P: n/a
Dan, we're we're having a conversation here, not writing a standard.
You insist on nit-picking every little nuance, even when the intent is
perfectly clear to anyone who's willing to pay some attention. It's a
waste of everybody's time.

--
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.
Nov 14 '05 #29

P: n/a
> Your original question should have been:
"Is there a scope resolution operator in C?"

The answer is NO. If you think about it (it took me a
while but then I am slow) you will see that there is
no need for such an operator in C.

No inheritance hence no need for scope resolution!

It seems that those who decide upon C specifications are
more apt to apply Occam's razor than not. Which, IMHO,
is just as well.

I suspect that the interviewer was interested not in the
answer itself but rather if you have grasped the concepts
of C++.


Hi Dan,

Thanks a lot for your wonderful explanation. Thanks a lot.

Regards,
Mohan.
Nov 14 '05 #30

P: n/a
Hi Kal,

Sorry for mentioning the name wrongly.

Regards,
Mohan.
Nov 14 '05 #31

P: n/a
In <ln************@nuthaus.mib.org> Keith Thompson <ks***@mib.org> writes:
Dan, we're we're having a conversation here, not writing a standard.
You insist on nit-picking every little nuance, even when the intent is
perfectly clear to anyone who's willing to pay some attention.
Please explain how you can deduce this perfectly clear intent using as
input the original post and nothing else. I am all ears.
It's a waste of everybody's time.


I'm afraid you're wasting everybody's time with a claim that cannot be
supported.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #32

P: n/a
Da*****@cern.ch (Dan Pop) writes:
In <ln************@nuthaus.mib.org> Keith Thompson <ks***@mib.org> writes:
Dan, we're we're having a conversation here, not writing a standard.
You insist on nit-picking every little nuance, even when the intent is
perfectly clear to anyone who's willing to pay some attention.


Please explain how you can deduce this perfectly clear intent using as
input the original post and nothing else. I am all ears.
It's a waste of everybody's time.


I'm afraid you're wasting everybody's time with a claim that cannot be
supported.


Dan, if you really want to discuss this further, send me an e-mail and
we can do so privately. I'm not going to continue this in the
newsgroup. (I might change my mind if someone other than you
specifically asks that we discuss it in the newsgroup.)

--
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.
Nov 14 '05 #33

P: n/a
In <ln************@nuthaus.mib.org> Keith Thompson <ks***@mib.org> writes:
Da*****@cern.ch (Dan Pop) writes:
In <ln************@nuthaus.mib.org> Keith Thompson <ks***@mib.org> writes:
>Dan, we're we're having a conversation here, not writing a standard.
>You insist on nit-picking every little nuance, even when the intent is
>perfectly clear to anyone who's willing to pay some attention.


Please explain how you can deduce this perfectly clear intent using as
input the original post and nothing else. I am all ears.
>It's a waste of everybody's time.


I'm afraid you're wasting everybody's time with a claim that cannot be
supported.


Dan, if you really want to discuss this further, send me an e-mail and
we can do so privately.


If you have anything to say, say it here, the discussion is still topical.
Whoever lost interest has already killfiled the thread.

Since you don't seem to get it, here is an analogy that could make things
easier for you to understand:

OP: How can I write a C program to display the message "Hello world"?

Responder:

#include <stdio.h>

int main()
{
printf("Hello world\n");
return 0;
}

OP: You idiot, my interview question required no semicolons and your
program has two semicolons!

Keith-the-smart: The OP's question wasn't clear, but, upon a short
reflection, it became clear to me that he wanted a solution with no
semicolons. Probably because I know other languages where such a
solution doesn't require any semicolons.
If this analogy is broken, please explain why.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #34

P: n/a
Da*****@cern.ch (Dan Pop) writes:
In <ln************@nuthaus.mib.org> Keith Thompson <ks***@mib.org> writes:
Da*****@cern.ch (Dan Pop) writes:
In <ln************@nuthaus.mib.org> Keith Thompson <ks***@mib.org> writes:
>Dan, we're we're having a conversation here, not writing a standard.
>You insist on nit-picking every little nuance, even when the intent is
>perfectly clear to anyone who's willing to pay some attention.

Please explain how you can deduce this perfectly clear intent using as
input the original post and nothing else. I am all ears.

>It's a waste of everybody's time.

I'm afraid you're wasting everybody's time with a claim that cannot be
supported.


Dan, if you really want to discuss this further, send me an e-mail and
we can do so privately.


If you have anything to say, say it here, the discussion is still topical.
Whoever lost interest has already killfiled the thread.


No, the discussion is not topical. (I've added an '[OT]' tag to the
subject header.)

Dan, in the quoted paragraph above, the phrase "even when the intent
is perfectly clear" was not a reference to the original article that
started this thread. It was a reference to something I wrote a few
articles upthread, which you insisted on misinterpreting. I no longer
remember, or care, exactly what it was.

I could have clarified that point, but given the history of
discussions in which you and I have participated, I assumed it would
only have led to further confusion. I assumed that if you cared, you
would contact me by e-mail as I suggested, or that if you didn't care
you would let the matter drop. My offer to take this to e-mail still
stands; if it's that important to you, I'll go back through the
archives and try to straighten out any misunderstandings. But I will
not do so in this newsgroup. I believe that every question in this
thread that's of any possible relevance to C has already been
answered.

--
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.
Nov 14 '05 #35

P: n/a
In <ln***************@nuthaus.mib.org> Keith Thompson <ks***@mib.org> writes:
Da*****@cern.ch (Dan Pop) writes:
In <ln************@nuthaus.mib.org> Keith Thompson <ks***@mib.org> writes:
>Da*****@cern.ch (Dan Pop) writes:
>> In <ln************@nuthaus.mib.org> Keith Thompson <ks***@mib.org> writes:
>> >Dan, we're we're having a conversation here, not writing a standard.
>> >You insist on nit-picking every little nuance, even when the intent is
>> >perfectly clear to anyone who's willing to pay some attention.
>>
>> Please explain how you can deduce this perfectly clear intent using as
>> input the original post and nothing else. I am all ears.
>>
>> >It's a waste of everybody's time.
>>
>> I'm afraid you're wasting everybody's time with a claim that cannot be
>> supported.
>
>Dan, if you really want to discuss this further, send me an e-mail and
>we can do so privately.


If you have anything to say, say it here, the discussion is still topical.
Whoever lost interest has already killfiled the thread.


No, the discussion is not topical. (I've added an '[OT]' tag to the
subject header.)

Dan, in the quoted paragraph above, the phrase "even when the intent
is perfectly clear" was not a reference to the original article that
started this thread. It was a reference to something I wrote a few
articles upthread, which you insisted on misinterpreting. I no longer
remember, or care, exactly what it was.


So, you're completely incoherent.

I objected to your claim that the OP's intent could be derived from the
original question, even if it was not very clearly formulated. I claim
that the original question was clearly formulated and did NOT reflect the
OP intent. See also my analogy, that you removed in your reply.

If you maintain your claim, please justify it, rather than talking
about anything else in a desperate attempt to muddle the issue, as
you did with your "perfectly clear intent" above. We're [OT] now,
so you have no reason to hide behind false topicality scruples.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #36

P: n/a
I repeat:
>Dan, if you really want to discuss this further, send me an e-mail and
>we can do so privately.


I'm done here.

--
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.
Nov 14 '05 #37

P: n/a
In <ln************@nuthaus.mib.org> Keith Thompson <ks***@mib.org> writes:
I repeat:
>> >Dan, if you really want to discuss this further, send me an e-mail and
>> >we can do so privately.


I'm done here.


Do you have anything to hide from the rest of people who might be still
following this discussion?

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #38

P: n/a
In article <ln************@nuthaus.mib.org>,
Keith Thompson <ks***@mib.org> wrote:
....
I think most of the regulars here have either stopped reading Dan
Pop's postings or have learned to apply a mental "Dan Pop filter",
reading for technical content (which is usually very good) and
ignoring the abuse.


I may or may not qualify as a regular, but I read this NG with a "technical
content" filter - i.e., it filters out any extraneous technical content.
I read this NG for the abuse (it is so much fun) - and I'd imagine that is
true for most of the regulars. Surely, we all know about as much C as we
need to, so there's not much point in reading this in the hopes of
learning. Reading for abuse is so much more entertaining.

Nov 14 '05 #39

P: n/a
On Sat, 21 Aug 2004 18:07:37 GMT, in comp.lang.c ,
ga*****@yin.interaccess.com (Kenny McCormack) wrote:
(stuff)

Troll alert.

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 14 '05 #40

P: n/a
In article <io********************************@4ax.com>,
Mark McIntyre <ma**********@spamcop.net> wrote:
On Sat, 21 Aug 2004 18:07:37 GMT, in comp.lang.c ,
ga*****@yin.interaccess.com (Kenny McCormack) wrote:
(stuff)

Troll alert.


troll, n., (Incorrect, but common among the lower classes, definition
follows): Someone I disagree with.

Nov 14 '05 #41

P: n/a
On Mon, 23 Aug 2004 14:29:40 GMT, in comp.lang.c ,
ga*****@yin.interaccess.com (Kenny McCormack) wrote:
In article <io********************************@4ax.com>,
Mark McIntyre <ma**********@spamcop.net> wrote:
On Sat, 21 Aug 2004 18:07:37 GMT, in comp.lang.c ,
ga*****@yin.interaccess.com (Kenny McCormack) wrote:
(stuff)

Troll alert.


troll, n., (Incorrect, but common among the lower classes, definition
follows): Someone I disagree with.


_____________________
/| /| | |
||__|| | Please do not |
/ O O\__ | feed the |
/ \ | Trolls |
/ \ \|_____________________|
/ _ \ \ ||
/ |\____\ \ ||
/ | | | |\____/ ||
/ \|_|_|/ | _||
/ / \ |____| ||
/ | | | --|
| | | |____ --|
* _ | |_|_|_| | \-/
*-- _--\ _ \ | ||
/ _ \\ | / `
* / \_ /- | | |
* ___ c_c_c_C/ \C_c_c_c____________
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 14 '05 #42

P: n/a
In article <eo********************************@4ax.com>,
Mark McIntyre <ma**********@spamcop.net> wrote:
On Mon, 23 Aug 2004 14:29:40 GMT, in comp.lang.c ,
ga*****@yin.interaccess.com (Kenny McCormack) wrote:
In article <io********************************@4ax.com>,
Mark McIntyre <ma**********@spamcop.net> wrote:
On Sat, 21 Aug 2004 18:07:37 GMT, in comp.lang.c ,
ga*****@yin.interaccess.com (Kenny McCormack) wrote:
(stuff)

Troll alert.


troll, n., (Incorrect, but common among the lower classes, definition
follows): Someone I disagree with.


_____________________
/| /| | |
||__|| | Please do not |
/ O O\__ | feed the |
/ \ | Trolls |
/ \ \|_____________________|


Um, talking to yourself, are you?

If, by your lights, I'm a troll, then aren't you ignoring your own advice?

Nov 14 '05 #43

P: n/a
ga*****@yin.interaccess.com (Kenny McCormack) writes:
In article <eo********************************@4ax.com>,
Mark McIntyre <ma**********@spamcop.net> wrote:
On Mon, 23 Aug 2004 14:29:40 GMT, in comp.lang.c ,
ga*****@yin.interaccess.com (Kenny McCormack) wrote:
In article <io********************************@4ax.com>,
Mark McIntyre <ma**********@spamcop.net> wrote:
On Sat, 21 Aug 2004 18:07:37 GMT, in comp.lang.c ,
ga*****@yin.interaccess.com (Kenny McCormack) wrote:
(stuff)

Troll alert.

troll, n., (Incorrect, but common among the lower classes, definition
follows): Someone I disagree with.


_____________________
/| /| | |
||__|| | Please do not |
/ O O\__ | feed the |
/ \ | Trolls |
/ \ \|_____________________|


Um, talking to yourself, are you?

If, by your lights, I'm a troll, then aren't you ignoring your own advice?


Troll! No, you're a troll! Am not! Are too! Are not! Am too!
TROLLTROLLTROLLTROLLTROLLTROLLTROLLTROLLTROLLTROLL TROLLTROLLTROLL

(Anyone who hasn't been a troll is encouraged to assume that my
ridicule is not directed at them.)

Followups redirected appropriately.

--
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.
Nov 14 '05 #44

P: n/a
Kenny McCormack wrote:
Mark McIntyre wrote:
[snip]
Um, talking to yourself, are you?

If, by your lights, I'm a troll, then aren't you ignoring your own advice?


Hi Kenny,

Mark McIntyre is one of our indigenous trolls.
Please ignore him.
Nov 14 '05 #45

This discussion thread is closed

Replies have been disabled for this discussion.