473,480 Members | 3,106 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Please Can Anny One Tell What This Declaration Says ?

typedef void(*FP);
FP UserMenuFunk[7];
FP UserFunk[7];

Please your comments on this help me lot .

May 15 '06 #1
4 1231
Possible typo:
`void(*FP)' should be replaced by `void(*FP)()'
that is `FP' is a function pointer to the function which takes no
argument
and return nothing. See example below:

#include <stdio.h>

typedef void(*FP)();
FP UserMenuFunk[7];
FP UserFunk[7];

void some_func() {
printf("some_func");
}

int main() {
UserMenuFunk[0] = some_func;
UserMenuFunk[0]();
}

May 15 '06 #2
ro*************@gmail.com wrote:
Possible typo:
`void(*FP)' should be replaced by `void(*FP)()'
that is `FP' is a function pointer to the function which takes no
argument and return nothing. See example below:


not necessarily. look at the following code sample. Here FP is a
defined type that represents a void pointer. and UserMenuFunk and
UserFunk are arrays of type FP and size 7 each.

/*CODE BEGINS*/
#include <stdio.h>
typedef void(*FP);

int main (int argc, char* argv[]) {
FP UserMenuFunk[7];
FP UserFunk[7];
char *a = "blah blah blah\n";
int b = 125;
int i = 0;
while (i < 7) {
UserMenuFunk[i] = a;
*(int*)&UserFunk[i] = b;
i++;
}
i = 0;
while (i < 7) {
printf("%d: %s\n", *(int*)&UserFunk[i],
(char*)UserMenuFunk[i]);
i++;
}
return 0;
/*CODE ENDS*/

May 15 '06 #3
Please include context!
[context restored]

code break <pk*****@gmail.com> wrote:
typedef void(*FP);
FP UserMenuFunk[7];
FP UserFunk[7];

Please your comments on this help me lot .

ro*************@gmail.com wrote: Possible typo:
`void(*FP)' should be replaced by `void(*FP)()'
Maybe, maybe not. The declaration
typedef void(*FP);
is also valid and `FP' is type `pointer to void'.
that is `FP' is a function pointer to the function which takes no
argument
No, no, no. The declaration
typedef void(*FP)();
means the function takes unspecified number of arguments.
and return nothing. See example below:

#include <stdio.h>

typedef void(*FP)();
FP UserMenuFunk[7];
FP UserFunk[7];

void some_func() {
printf("some_func");
}
void some_func1(int x, int y) { /*...*/ }

int main() {
UserMenuFunk[0] = some_func;
UserMenuFunk[0](); UserMenuFunk[1] = some_func1;
UserMenuFunk[1](7, 11); /* ok */ }


--
Stan Tobias
mailx `echo si***@FamOuS.BedBuG.pAlS.INVALID | sed s/[[:upper:]]//g`
May 15 '06 #4
On 15 May 2006 05:39:44 -0700, "code break" <pk*****@gmail.com> wrote:
typedef void(*FP);
FP UserMenuFunk[7];
FP UserFunk[7];

Please your comments on this help me lot .


The parentheses are just a confusion factor.

FP is a typedef (synonym) for pointer to void.

UserMenuFunck and UserFunk are each an array of 7 pointer to void.

If the typedef had been void "(*FP)()" (at least the original
parentheses would make sense), then FP would have been a synonym for
pointer to function.
Remove del for email
May 21 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
3896
by: Thomas G. Marshall | last post by:
This message is sent to these newsgroups because they are no longer valid: comp.lang.java comp.lang.java.api comp.lang.java.bugs comp.lang.java.misc comp.lang.java.setup comp.lang.java.tech
16
1559
by: hoggmeister | last post by:
Hi, Im new to C coming from a java background. I having difficulty adjusting to C and was hoping someone could help me with a little simple code to get started. I would like a little program...
31
2587
by: DeltaOne | last post by:
#include<stdio.h> typedef struct test{ int i; int j; }test; main(){ test var; var.i=10; var.j=20;
20
3530
by: Blah | last post by:
In MSDN documentation it states.. Remarks The constant declaration can declare multiple constants, for example: public const double x = 1.0, y = 2.0, z = 3.0; The static modifier is not...
36
2051
by: Cap'n Ahab | last post by:
I have used VB3 - VB6, so learning all this OO stuff is reasonably new to me (although I looked at Java a few years ago). Anyway, I thought I would write a small class to begin with, with a...
13
2402
by: Miro | last post by:
Ok I have been slowely - and ever so slowely teaching myself VB.net Currently I have created an MDB file by code, and added fields to the MDB file by code. I like this solution because, ( im...
25
2771
by: venky | last post by:
Hi main() { int x; /* it declaration or defination??*/ }
0
1552
by: TONY-GAL | last post by:
To: All European Citizens who care about Animals This is a critical time. The European Commission (EC) is currently revising the law - known as Directive 86/609 - that governs animal experiments...
7
1369
by: james | last post by:
Hi, I'm new to C++, and coming from a dynamically-typed language, I'm finding the data types difficult. My goal at the moment is to append a string that is typed as a command line argument into...
0
7061
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7110
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6763
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5367
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4799
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3011
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
574
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
210
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.