Author |
Message |
guopeter
|
Posted: Mon Feb 04, 2008 1:53 pm Post subject: 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!!! |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
md
![](http://compsci.ca/v3/uploads/user_avatars/1849317514ed6c4399768d.png)
|
Posted: Mon Feb 04, 2008 5:27 pm Post subject: RE:Counter in C |
|
|
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 ![Razz Razz](http://compsci.ca/v3/images/smiles/icon_razz.gif) |
|
|
|
|
![](images/spacer.gif) |
Parliam
|
Posted: Wed May 28, 2008 11:11 am Post subject: Re: Counter in C |
|
|
int count=0;
int variable_number=0;
for(i=0;i<variable_number;i++)
{
variable_number=i;
count+=1;
}
the program's have express your means ?? |
|
|
|
|
![](images/spacer.gif) |
md
![](http://compsci.ca/v3/uploads/user_avatars/1849317514ed6c4399768d.png)
|
Posted: Thu May 29, 2008 8:51 pm Post subject: RE:Counter in C |
|
|
Parliam, this thread is kinda old and we frown on reviving old threads.
Also, your code does not work; give it a try in a debugger and you'll see why ![Wink Wink](http://compsci.ca/v3/images/smiles/icon_wink.gif) |
|
|
|
|
![](images/spacer.gif) |
Parliam
|
Posted: Tue Jun 03, 2008 5:59 am Post subject: RE:Counter in C |
|
|
okay,i have seen the results,thz!! |
|
|
|
|
![](images/spacer.gif) |
|