Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Do you actually know what *p++ does in C? (denniskubes.com)
1 point by musepwizard on Aug 14, 2012 | hide | past | favorite | 3 comments


Yes, I do. Unfortunately the author of this article doesn't, and didn't bother to test his examples before making entirely false claims.

The following example will do something very different from what the article says:

  int myarray[4]= {1,2,3,0};
  int *p = myarray;
  while ((*p)++) {
    printf("%d ", *p);
  }


Hi lmm. Thanks for catching that. I have updated the article code with the fixes. This is my first blog post ever. That will teach me not to post without fulling checking the code.


It needs parentheses, because even if you know what it does, the code might one day be maintained by someone who doesn't.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: