Simulated product dispenser

Dependencies:   HTS221

Fork of mbed-cloud-workshop-connect-HTS221 by Jim Carver

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ProductionCode.c Source File

ProductionCode.c

00001 
00002 #include "ProductionCode.h"
00003 
00004 int Counter = 0;
00005 int NumbersToFind[9] = { 0, 34, 55, 66, 32, 11, 1, 77, 888 }; //some obnoxious array to search that is 1-based indexing instead of 0.
00006 
00007 // This function is supposed to search through NumbersToFind and find a particular number.  
00008 // If it finds it, the index is returned.  Otherwise 0 is returned which sorta makes sense since 
00009 // NumbersToFind is indexed from 1.  Unfortunately it's broken 
00010 // (and should therefore be caught by our tests)
00011 int FindFunction_WhichIsBroken(int NumberToFind)
00012 {
00013     int i = 0;
00014     while (i <= 8) //Notice I should have been in braces
00015         i++;
00016         if (NumbersToFind[i] == NumberToFind) //Yikes!  I'm getting run after the loop finishes instead of during it!
00017             return i;
00018     return 0;
00019 }
00020 
00021 int FunctionWhichReturnsLocalVariable(void)
00022 {
00023     return Counter;
00024 }