title: how do i print out array values in outside a function it has been modified
body: <pre><code>void sort(int values[], int n);  
  
  void modify_all_aray_values_to_0(int value[], int array_size);
  
  int main(void)
  {
      int aray[] = {4,2,56,2,1,7,20,9,3,5,6,4,3,2,44,57};
      int size_of_aray = sizeof(aray)/sizeof(aray[0]);
      sort(aray, size_of_aray);
      printf("\n");
  }
  
  void sort(int values[], int n)
  {
      // TODO: implement a sorting algorithm
      int temporary;
      //assumes temporary array size will not exceed 1000
      int temporary_array[1000];
      int size_of_tmp_array = sizeof(temporary_array)/sizeof(temporary_array[0]);
      //set all values in temporary array to 0
      modify_all_aray_values_to_0(temporary_array, size_of_tmp_array);
      for(int i = 0; i &lt; n; i++)
      {
          //store the values of values[] i'th in temporary variable
          //at this stage, temporary = 4, because first element in values[] is 4
          temporary = values[i];
          //store result of temporary_array[4]+1 in temporary_array[4]
          //at this stage temporary_array[4],s values is 0
          //when i assigned it, it gets the value (0) and increament it with 1
          //this means so far i have seen value 4 once in values[]
          /*so if this loops again and it found value 4, it will
          modify and increament temporary_array value to 2*/
          temporary_array[temporary] = temporary_array[temporary]+1;
          //so at the end of the loop
          //temporary_array[1] = 1
          //temporary_array[2] = 3
          //temporary_array[3] = 2
          //temporary_array[4] = 2 and so on...
      }
      int tu;
      //print all values in values[] before it get modified
      for(int i = 0; i &lt; n; i++)
      {
          printf("%i-", values[i]);
      }
      printf("\n");
      //assumes it wont loop more than 100 times
      for(int i = 0; i &lt; 100; i++)
      {
          if(temporary_array[i] &gt; 0)
          {
              for(tu = 0; 0 &lt; temporary_array[i]; tu++ )
              {
                  //modify valeus[] by assigning i'th value
                  //at this stage if when temporary_array[1] is greater than 0
                  //store 1 in values[0]
                  values[tu] = i;
                  //immediately decrease temporary_array[1] by 1
                  //now temporary_array[1] is now 0
                  //next time the loop will check if its greater than 0
                  //if so it will modify values[] and store the value
                  //else it wont bother and that means 1 doesnt appear in array again
                  temporary_array[i] = temporary_array[i]-1;
                  //print values[0] inside loop after modification
                  printf("%i,", values[tu]);
                  //printed 1
                  //will print 1,2,2,2,3,3... and so on after compilation
              }
          }
      }
      printf("\n");
      for(int i = 0; i &lt; n; i++)
      {
          //print values[0] outside the previous loop
          printf("%i-", values[i]);
          //this time around it printed 57 instead of 1
          //prints 57-4-2-2-1-7-20... and so on
          //what could have happend?
      }
      printf("\n");
      return;
  }
  
  void modify_all_aray_values_to_0(int value[], int array_size)
  {
      for(int i = 0; i &lt; array_size; i++)
      {
          value[i] = 0;
      }
  }
  </code></pre>
  
  <p>Please help me out with this.
  I have posted this question before but it was not OK and understandable, so I decided to delete the question and studied the users comment just to learn from my mistakes so that I'll be able to ask questions that will be understood by us.</p>
  
  <p>I have really practised the code formatting and I thank god for it now that it is better than the previous post I posted.</p>