4 ms·
Can you program in C effectively without pointers?
by gigatexal 6y ago
Can you program in C effectively without pointers?
- klyrs 6y agoDepends 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.
- WalterBright 6y agoArrays in C (once passed to functions) are pointers, even when they use array syntax: https://www.digitalmars.com/articles/C-biggest-mistake.html https://www.digitalmars.com/articles/C-biggest-mistake.html
- klyrs 6y agoYou 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.
- illuminated 6y agoNope, therefore you cannot do it effectively if you do not understand them :)
- Gibbon1 6y agoYou can program C effectively without pointer arithmetic. Storing copies of pointers for later is usually a bad idea.