I'm attempting to do a "find the bug" assignment, and this small bit of C code (not runnable as is) is supposed to have a bug in it. Unforunately I can't find one. I put it into runnable code and it seems to run as expected...is this a trick question or am I missing something? Any help is greatly appreciated.
Code snippit:
void example(int a[10]){
        int i = 0;
        do {
           a[i] = i++;
        }while (i < 10);
    }
My runnable code:
#include <stdio.h>
#include <string.h>
example(int a[10]){
    int i = 0;
    do {
       a[i] = i++;
       printf("%i", a[i-1]);  //decremented by 1 to offset i
    }while (i < 10);
}
int main(void)
{
   int arr[10];    
   example(arr);
   return 0;
}
Output:
0123456789
 
    