
-----------------------------------
guopeter
Mon Feb 04, 2008 1:53 pm

Counter in C
-----------------------------------
Hi, I'm having difficulty programming a switch counter.

Basically what I need is a program that adds 1 to the variable every time a switch goes from 1 to 0 and 0 to 1.

Now it's getting frustrating..
So if anyone can help that'll be greatly appreciated!!!
THANKS!!!

-----------------------------------
md
Mon Feb 04, 2008 5:27 pm

RE:Counter in C
-----------------------------------

int count = 0;
int flip = 0, old_flip=0;
while(true)
{
    if( flip != old_flip )
    {
        count++;
        old_flip = flip;
    }
}


Is that what you mean? Clearly something would have to be added to cause flip to change in my example... I didn't write that :P

-----------------------------------
Parliam
Wed May 28, 2008 11:11 am

Re: Counter in C
-----------------------------------
int  count=0;
int variable_number=0;
for(i=0;i