I did a recursion exercise and I could not understand what is the difference between doing *p++
or *p+=1.
Both of them should add 1 to the value pointed at but for some reason *p+=1
works and *p++
doesn't.
void rec(char a[], int *p ,int i)
{
if(a[i+1]== '\0')
return;
if(a[i]==a[i+1])
*p+=1;
rec(a, p, i+1);
}
void rec(char a[], int *p ,int i)
{
if(a[i+1]== '\0')
return;
if(a[i]==a[i+1])
*p++;
rec(a, p, i+1);
}