Hacker News new | past | comments | ask | show | jobs | submit login

Can you program in C effectively without pointers?



Nope, therefore you cannot do it effectively if you do not understand them :)


Depends on what you mean by "effectively." If you wanna, say, do an exhaustive search over all 4-dimensional integer vectors in a rectangular region, and print off the ones that satisfy some relationship, you don't need pointers (nevermind what printf and string literals are doing under the hood). It's a wonderfully beefy desktop calculator, in that way. But for most applications, pointers are pretty much necessary.


Arrays in C (once passed to functions) are pointers, even when they use array syntax:

https://www.digitalmars.com/articles/C-biggest-mistake.html


You don't need arrays for the code I was describing: it's a nested for-loop on 4 ints.

But, yeah, that's a really common mistake.


You can program C effectively without pointer arithmetic. Storing copies of pointers for later is usually a bad idea.




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

Search: