|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 (permalink) |
|
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 (permalink) |
|
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 (permalink) |
|
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 (permalink) |
|
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 (permalink) |
|
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 (permalink) |
|
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 (permalink) |
|
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 (permalink) |
|
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 |
|
![]() |
| Outils de la discussion | |
|
|