Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

names of the best books to buy

Status
Not open for further replies.
return valueA **pointer; // This is perfectly good, but how can you tell what the hell is going on here.. This returns the value 2*5. Really bad syntax.

Your right.... At first glace I thought you were introducing newbies to pointer pointers.... That would be fun to watch...
 
Your right.... At first glace I thought you were introducing newbies to pointer pointers.... That would be fun to watch...

Arrays of function pointers that take in function pointers and return function pointers.. not to mention the type of function pointers taken in and returned.. that is something.. useless. But still they ask about them in exams. Sometimes I hate "academic discussion".. sometimes I love it.
 
In my 30 years programming... I must have used function arrays... oooh let me see..... Oh yeah... NEVER..

One guy I knew used them extensively for his menuing systems..... Soon get lost, I'm the worst in the world for remarking my code...
 
Many I know use pointer purely because it makes them look clever.
IMHO apart from memory accessing ports in an embedded system, they are only really useful for "returning" (or modifiying sent values) more than one variable from a function. Error correction is where I have used them. Send a value to a function and modify the sent variable as part of the function by adding the error correction bits to the sent value like you would with POCSAG encoding.

There are easier ways of making a menu system in C without function pointers. I prefer embedded case statements. More readable, debuggable and probably produce the same asm anyway.

To myself, readablilty outweighs smaller C files as it could be years before I look at them again. If I wanted speed/efficiency I would use assembly anyway as pointers are more inherent in the language as learning asm makes you understand direct and indirect addressing from the start.
 
IMHO apart from memory accessing ports in an embedded system, they are only really useful for "returning" (or modifiying sent values) more than one variable from a function. Error correction is where I have used them. Send a value to a function and modify the sent variable as part of the function by adding the error correction bits to the sent value like you would with POCSAG encoding.

Most common use of pointers is working with strings. Second is passing structures as parameters to functions. And related to that are data-structures like linked lists etc. In "higher level" programming languages pointers are hidden behind "value types" and "reference types".. nothing changes but the name.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top