Concept of function pointers in C? [duplicate] - c

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
What is the point of function pointers?
hi all,
I want to get the basic and concrete idea of function pointers in C language.
ie 1) its usage in C
2) main applications it is currently using
3) unique features
4) its scope in embedded applciations etc
Hoping your co operation in this too.
__Kanu

Function Pointers are pointers, that is variables, which point to the address of a function.
Nice example here. Also this answer is a must read.

Related

Non-copyable struct in C? [duplicate]

This question already has answers here:
How do you implement a class in C? [closed]
(16 answers)
Closed 3 years ago.
After reading this page, I already know how to implement non-copyable
classes in C++.
(How do I make this C++ object non-copyable?)
Now I want implement non-copyable in C,
But I don't find similar code in C.
So I want to ask how to implement in C.
You can do this using opaque pointers. The idea is:
You define a struct somewhere and you define all of its operations in terms of a pointer to that struct. That would probably be a standalone compilation unit.
The consumers of your struct only get a declaration but not the full definition of that struct, which means that they don't know the layout or even the size of the struct. It follows that they are able to receive, store, and pass around any pointers to that struct, but not values of it.

In C++11 when should we explicitly use std::decay? [duplicate]

This question already has answers here:
What is std::decay and when it should be used?
(2 answers)
Closed 6 years ago.
We know that compiler will decay array/function to pointers when needed(according to context), then when is the time we should explicitly use std::decay?
Is there any task that requires us to use it, or else, compiler doesn't know how to handle it?
Thanks.
Simply put, decay::type is the identity type-transformation except if T is an array type or a reference to a function type. In those cases the decay::type yields a pointer or a pointer to a function, respectively.
For more detail please see this https://stackoverflow.com/a/25732651/1691223

Is there a shell for quickly experimenting in C? [duplicate]

This question already has answers here:
Is there an interpreter for C? [closed]
(13 answers)
Closed 7 years ago.
I'm not looking for csh, I'm looking for a shell for C similar to the Python or the Scala shells.
I understand that C is a compiled language, but is there anything out there that would let me quickly play around with things so I can e.g. better learn how pointers work? It should at least be theoretically possible to do this, wondering if anyone has taken the time to implement it.
As you well know that C is a compiled language. It is better to write C code than compile it, do some breakpoints, learn what value is in memory, where the pointer points etc.
But I think you mean this. Is there an interpreter for C?

Getting an overflow when creating an integer array? [duplicate]

This question already has answers here:
what is causing SIGSEV?
(3 answers)
Closed 8 years ago.
I am getting an overflow for using this.
int x[471][640];
Someone told me to use Malloc? I have no idea what that is. Its not in my book nor my lectures. Any fix to this?
If you do not know yet about C function malloc then you can try another approach. For example declare your local array as
static int x[471][640];
that is as having static storage duration.
If you also do not know yet about the keyword static then the only approach I can suggest is to declare the array globally that is outside any function. for example before main:)

How do we normalize a pointer? [duplicate]

This question already has answers here:
what is meant by normalization in huge pointers
(3 answers)
Closed 9 years ago.
Actually i was studying about huge and far pointers.
I come to know huge pointers are by default in normalized form.
I want to know how can we normalize any pointer?
The huge pointer and far pointer are old concept which live in 16-bit
DOS time. You can search something about DOS programming for more
detail about them.
In 8086 programming (MS DOS), a far pointer is normalized if its offset part is between 0 and 15 (0xF).

Resources