c - printBackward recursion doesn't print first element of array when using operator ++ -


i wanna print integer array backward , detect when using ++ instead of "startpos + 1" result comes lose first element of array. debugged understand problem, recursion works strange. can explain problem is? thank much.

#include <stdio.h> #define size 10  void printbackward(const int[], const int size, int startposition);  int main(void) {     const int a[size] = {1,3,5,7,9,10,13,15,17,19};     printbackward(a,size,0);     puts(""); } void printbackward(const int a[size], const int size, int startpos) {     if(startpos < size)     {         printbackward(a,size,++startpos); // work wrongly ++startpos                 //printbackward(a,size,startpos + 1); // work         printf_s("%4d",a[startpos]);     } } 

passing startpos + 1 function not change value of startpos. however, ++startpos increments value of startpos. 2 not interchangeable.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -