|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
hi friends,
is it possible to call a variable from the main function to a sub fuction with out sending as a argument, pointer and can't declare as global variable? void main() { int a=10; fun(); } fun() { printf("%d", a); } condition 1. don't use pointer concept 2.don't declare as global variable 3.don't send as arguments IS IT POSSIBLE? please me |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Tue, 16 Oct 2007 21:20:49 +0200, Ant Franck wrote:
> hi friends, > > is it possible to call a variable from the main function to a sub > fuction with out sending as a argument, pointer and can't declare as > global variable? [...] > condition > 1. don't use pointer concept > 2.don't declare as global variable > 3.don't send as arguments > > IS IT POSSIBLE? Why would you want to? Anyway, it depends on what at least "as", "global", and "variable" mean. With some legitimate interpretations, there are certainly ways around the pointless restrictions you (or your instructor) gave. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Ant Franck wrote:
> hi friends, > > is it possible to call a variable from the main function to a sub > fuction with out sending as a argument, pointer and can't declare as > global variable? > > void main() > { > int a=10; > fun(); > } > > fun() > { > printf("%d", a); > } > > condition > 1. don't use pointer concept > 2.don't declare as global variable > 3.don't send as arguments Why? Brian |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
[comp.lang.c] Ant Franck <nospam@nospam.com> wrote:
> is it possible to call a variable from the main function to a sub > fuction with out sending as a argument, pointer and can't declare as > global variable? Search the archives of this group for the answer, which is "do your own homework"... > void main() ....and get a professor with a clue... > printf("%d", a); ....and terminate your output with a newline. -- C. Benson Manica | I appreciate all corrections, polite or otherwise. cbmanica(at)gmail.com | ----------------------| I do not currently read any posts posted through sdf.lonestar.org | Google groups, due to rampant unchecked spam. |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
In article <slrnfha3oa.tua.nospam@nospam.com>,
Ant Franck <nospam@nospam.com> wrote: >is it possible to call a variable from the main function to a sub >fuction with out sending as a argument, pointer and can't declare as >global variable? In some implementations, Yes. If you want to know *How* to do it, at the very least you'll have to google up my posting on the topic about 2 months ago, when someone presented the same question in almost exactly the same words. -- "I will speculate that [...] applications [...] could actually see a performance boost for most users by going dual-core [...] because it is running the adware and spyware that [...] are otherwise slowing down the single CPU that user has today" -- Herb Sutter |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
ok so how do you do it? can't find anything on google.
On 16 Oct 2007 at 20:49, Walter Roberson wrote: > In article <slrnfha3oa.tua.nospam@nospam.com>, > Ant Franck <nospam@nospam.com> wrote: >>is it possible to call a variable from the main function to a sub >>fuction with out sending as a argument, pointer and can't declare as >>global variable? > > In some implementations, Yes. > > If you want to know *How* to do it, at the very least you'll have > to google up my posting on the topic about 2 months ago, when > someone presented the same question in almost exactly the same words. |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
In article <slrnfhablv.fas.nospam@nospam.com>,
Ant Franck <nospam@nospam.com> wrote: >On 16 Oct 2007 at 20:49, Walter Roberson wrote: >> In article <slrnfha3oa.tua.nospam@nospam.com>, >> Ant Franck <nospam@nospam.com> wrote: >>>is it possible to call a variable from the main function to a sub >>>fuction with out sending as a argument, pointer and can't declare as >>>global variable? >> In some implementations, Yes. >> If you want to know *How* to do it, at the very least you'll have >> to google up my posting on the topic about 2 months ago, when >> someone presented the same question in almost exactly the same words. >ok so how do you do it? can't find anything on google. Just look up your previous thread, when you posted using the name "Anto Frank", using your email address j.antofranklin@gmail.com -- So you found your solution What will be your last contribution? -- Supertramp (Fool's Overture) |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
ok thanks. i stopped reading that when i got lots of unful and
unfreindly replies... do you have the url? On 16 Oct 2007 at 21:45, Walter Roberson wrote: > In article <slrnfhablv.fas.nospam@nospam.com>, > Ant Franck <nospam@nospam.com> wrote: > >>On 16 Oct 2007 at 20:49, Walter Roberson wrote: >>> In article <slrnfha3oa.tua.nospam@nospam.com>, >>> Ant Franck <nospam@nospam.com> wrote: >>>>is it possible to call a variable from the main function to a sub >>>>fuction with out sending as a argument, pointer and can't declare as >>>>global variable? > >>> In some implementations, Yes. > >>> If you want to know *How* to do it, at the very least you'll have >>> to google up my posting on the topic about 2 months ago, when >>> someone presented the same question in almost exactly the same words. > >>ok so how do you do it? can't find anything on google. > > Just look up your previous thread, when you posted using the > name "Anto Frank", using your email address j.antofranklin@gmail.com |
|
|
|
#9 |
|
Messages: n/a
Hébergeur: |
Ant Franck wrote:
> > hi friends, > > is it possible to call a variable from the main function to a sub > fuction with out sending as a argument, pointer and can't declare as > global variable? No. What teacher and/or school keeps giving students this question? It gets posted in nearly identical form every few weeks. > void main() > { > int a=10; > fun(); > } > > fun() > { > printf("%d", a); > } > > condition > 1. don't use pointer concept > 2.don't declare as global variable > 3.don't send as arguments > > IS IT POSSIBLE? The answer is that it's not possible unless you invoke undefined behavior whose behavior you happen to know because you know some intimate details about the particular compiler, including being tied to a specific version of that compiler and a particular set of compilation options. -- +-------------------------+--------------------+-----------------------+ | Kenneth J. Brody | www.hvcomputer.com | #include | | kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h> | +-------------------------+--------------------+-----------------------+ Don't e-mail me at: <mailto:ThisIsASpamTrap@gmail.com> |
|
|
|
#10 |
|
Messages: n/a
Hébergeur: |
(Top-posting corrected.]
Ant Franck wrote: > On 16 Oct 2007 at 21:45, Walter Roberson wrote: > > In article <slrnfhablv.fas.nospam@nospam.com>, > > Ant Franck <nospam@nospam.com> wrote: [...] > >>ok so how do you do it? can't find anything on google. > > > > Just look up your previous thread, when you posted using the > > name "Anto Frank", using your email address j.antofranklin@gmail.com > > ok thanks. i stopped reading that when i got lots of unful and > unfreindly replies... Why do you expect to get anything more useful than the "it cannot be done" answer you got the last time? > do you have the url? And when you can't even be bothered to look up your own messages, especially when you were posting from Google the last time (and even this one was routed through Google before it got to me), don't expect people to give you very much . -- +-------------------------+--------------------+-----------------------+ | Kenneth J. Brody | www.hvcomputer.com | #include | | kenbrody/at\spamcop.net | www.fptech.com | <std_disclaimer.h> | +-------------------------+--------------------+-----------------------+ Don't e-mail me at: <mailto:ThisIsASpamTrap@gmail.com> |
|
![]() |
| Outils de la discussion | |
|
|