473,511 Members | 9,983 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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
44 1973
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
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
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

"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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
>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
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
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
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
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
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
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
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
> 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
Hi Kal,

Sorry for mentioning the name wrongly.

Regards,
Mohan.
Nov 14 '05 #31
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
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
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
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
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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

88
5055
by: Tim Tyler | last post by:
PHP puts most of its functions into a big flat global namespace. That leads to short function names - but creates a namespace minefield for programmers. Lots of the functions are legacies from...
6
2092
by: Fernando Rodríguez | last post by:
Hi, I haven't used Python in quite some time, and I'm bit puzzled by this: counter = 0 class Blah(object): def run(self): counter += 1
2
2377
by: C Gillespie | last post by:
Dear All, I have 2 arrays var A1 = new Array(); A1 ="Y2"; var B1 = new Array(); B1 ="Y1"; B1 ="sink";
11
2530
by: Capstar | last post by:
Hi, I am working on an application, which will run embedded without an OS. The app is build up out of a couple of well defined parts. At first I wanted to keep those parts seperated and use...
9
356
by: Shilpa | last post by:
Hi, I just wanted to know whether we can access global variable within a local block , where both variables are having same name. For ex: int temp=5 ; { int temp=10;
9
2990
by: Ed Jensen | last post by:
I'm having a vexing problem with global variables in Python. Please consider the following Python code: #! /usr/bin/env python def tiny(): bar = for tmp in foo: bar.append(tmp) foo = bar
1
29312
weaknessforcats
by: weaknessforcats | last post by:
C++: The Case Against Global Variables Summary This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have...
112
5351
by: istillshine | last post by:
When I control if I print messages, I usually use a global variable "int silent". When I set "-silent" flag in my command line parameters, I set silent = 1 in my main.c. I have many functions...
4
3701
Dheeraj Joshi
by: Dheeraj Joshi | last post by:
Hi, I was wondering is there any technique available, so we can access the global variable inside a function if we have a local variable inside the function with the same name as global variable. ...
0
7251
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7148
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7430
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7089
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5673
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5072
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3217
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1581
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.