Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

C Masked Global Variable

Name: Anonymous 2009-05-14 5:52

How would I access the global variable tim from procedure()?

int tim = 0;

void procedure(int tim)
{
    global tim = local tim;
}

Name: Anonymous 2009-05-14 5:56

DON'T HELP HIM!!!

Name: Anonymous 2009-05-14 6:13

never mind, i'll just rename it then

Name: Anonymous 2009-05-14 6:42


int tim = 0;

void procedure(int tim)
{
    //Code here using tim
}

procedure(tim);

Name: Anonymous 2009-05-14 7:03

But how would i access the global variable tim from inside procedure?

e.g. in a C++ class, it would be like this:

class Jobby{
    int tim = 0;
   
    public void procedure(int tim)
    {
        this.tim = tim;
        // global = local
    }
}

Name: Anonymous 2009-05-14 7:03

>>5

Sorry, i meant, how would i do that in C?

Name: Anonymous 2009-05-14 7:07

You wouldn't.  You can't have duplicate variable names like that.

Name: Anonymous 2009-05-14 7:07

Right, thanks

That is all.

Name: Anonymous 2009-05-14 7:08

int(tim)=0;void(procedure)(int(tim)){int(tom)=tim;extern(tim);tim=tom;}

Name: Anonymous 2009-05-14 7:50

who is tim

Name: Anonymous 2009-05-14 7:57

my friendly variable

Name: Anonymous 2009-05-14 8:00

>>9
gcc doesn't like externing tim, i think

Name: Anonymous 2009-05-14 8:02

int tim = 0;
int *tom (int tum) {
    tim++;
    *tom (tim) = tum;
    return tim;
}
tim = tom (tim);

Name: Anonymous 2009-05-14 8:03

It's short for time, but EXPERT C PROGRAMMERS should never use more than 1 character for their variable names.

Name: Anonymous 2009-05-14 9:08

>>14
what about when you run have more than like 55 variables

Name: Anonymous 2009-05-14 9:14

>>15
all variables should be local anyway

Name: Anonymous 2009-05-14 9:22

>>16
get out, NON-EXPERT PROGRAMMER

Name: Anonymous 2009-05-14 10:28

>>16
avoid global variables whenever possible

Name: Anonymous 2009-05-14 10:37

>>14
Even though this should be completely absurd, it's terrifying how prevalent it is in the biggest open source projects.

In other words, not only does open source promote communism, it also supports TERRORISTS!

Name: Anonymous 2009-05-14 12:01

All function should e local as well, so use where and let in functional codans, and define all functions inside the main function in languages like PASCAL.

Name: Anonymous 2011-02-02 23:06

Name: Anonymous 2011-02-03 4:17

Don't change these.
Name: Email:
Entire Thread Thread List