PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.c > how to use a variable without reference
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
how to use a variable without reference

Réponse
 
LinkBack Outils de la discussion
Vieux 16/10/2007, 20h20   #1
Ant Franck
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut how to use a variable without reference

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

  Réponse avec citation
Vieux 16/10/2007, 20h34   #2
$)CHarald van D)&k
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how to use a variable without reference

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.
  Réponse avec citation
Vieux 16/10/2007, 20h38   #3
Default User
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how to use a variable without reference

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
  Réponse avec citation
Vieux 16/10/2007, 20h56   #4
Christopher Benson-Manica
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how to use a variable without reference

[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.
  Réponse avec citation
Vieux 16/10/2007, 21h49   #5
Walter Roberson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how to use a variable without reference

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
  Réponse avec citation
Vieux 16/10/2007, 22h36   #6
Ant Franck
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how to use a variable without reference

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.


  Réponse avec citation
Vieux 16/10/2007, 22h45   #7
Walter Roberson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how to use a variable without reference

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)
  Réponse avec citation
Vieux 16/10/2007, 23h54   #8
Ant Franck
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how to use a variable without reference

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




  Réponse avec citation
Vieux 17/10/2007, 14h21   #9
Kenneth Brody
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how to use a variable without reference

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>


  Réponse avec citation
Vieux 17/10/2007, 14h27   #10
Kenneth Brody
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how to use a variable without reference

(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>


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 05h02.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,15130 seconds with 18 queries