473,412 Members | 2,304 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

complicated declaration

Are the following declaration correct ??

int *p// p is a pointer to integer

int *p[]// p is an array of integer pointers

int (*p)[]// p is a pointer to an integer array

int *p()// p is a pointer to function returning
address of an integer(integer pointer)

int p(char *)//p is a function which takes a character pointer
as an argument and returns an integer

int *p(char *)// p is a function which takes a character pointer
as an argument and returns the address of an integer(integer pointer)

int (*p)(char *)// p is a pointer to a function which takes a
character pointer
as an argument and returns an integer

---------------------------------------------

int (*p(char*))[]// p is a pointer to a function and takes a character
pointer
as an argument and returns an array of integers

int p(char(*a)[])//p is a function which takes a pointer to a
character array
as an argument and returns an integer

int p(char*[])//p is a function which takes an array of character
pointers
as an argument and returns an integer

int *p(char a[])//p is a function which takes a character array
as an argument and returns an address of an integer(integer pointer)

int p(char (*a)[])//p is a function which takes a pointer to a
character array
as an argument and returns an integer

int *p(char *a[])//p is a function which takes an array of character
pointers
as an argument and returns the address of an integer(integer pointer)

int (*p)(char (*a)[])//p is a pointer to function which takes a
pointer
to a character array as an argument and returns an integer

int *(*p)(char(*a)[])//p is a pointer to function which takes a
pointer
to a character array as an argument and returns the address of an
integer(integer pointer)

--------------------------------------------

int *(*p)(char *a[])//p is a pointer to function which takes an array
of character pointers
as an argument and returns the address of an integer(integer pointer)

int (*p[])(void)//p is an array of pointers to function taking no
argument
and returning an integer

int (*p[])(char a)//p is an array of pointers to function taking a
character argument
and returning an integer

int *(*p[])(char a)//p is an array of pointers to function taking a
character argument
and returning an address of integer(integer pointer)

int *(*p[])(char *a)//p is an array of pointers to function taking a
character array as

argument and returning an address of integer(integer pointer)
Mar 13 '08 #1
3 1806
On Wed, 12 Mar 2008 23:54:25 -0700,asit wrote:
Are the following declaration correct ??
Yes, except the below one.

<snip>
>
int *p()// p is a pointer to function returning address of an
integer(integer pointer)
This is wrong. p is a function instead of a function pointer.
If you want it to be a pointer, you should:

int (*p)();

And note that it can take *any* arguments, the following statements
are correct.

int (*p)();
int (*q)(int);
int (*r)(void);
p = q;
p = r;
--
Hi, I'm a .signature virus, please copy/paste me to help me spread
all over the world.
Mar 13 '08 #2
On Mar 13, 1:54 am, asit <lipu...@gmail.comwrote:
Are the following declaration correct ??
[snip]
int *p()// p is a pointer to function returning
address of an integer(integer pointer)
Incorrect. p is a function returning a pointer to int. What you're
thinking of is

int *(*p)();

[snip]
int (*p(char*))[]// p is a pointer to a function and takes a character
pointer
as an argument and returns an array of integers
Incorrect in that functions may not return array types (or other
function types), although you clearly understand declarator syntax.
You can return a pointer to an array:

int (*(*p(char*)))[];

p is a pointer to a function taking a char* argument and returning a
pointer to an array of int.

[snip remainder]
Mar 13 '08 #3
John Bode <jo*******@my-deja.comwrites:
On Mar 13, 1:54 am, asit <lipu...@gmail.comwrote:
>Are the following declaration correct ??
<snip>
>int (*p(char*))[]// p is a pointer to a function and takes a character
pointer
as an argument and returns an array of integers

Incorrect in that functions may not return array types (or other
function types), although you clearly understand declarator syntax.
You can return a pointer to an array:

int (*(*p(char*)))[];

p is a pointer to a function taking a char* argument and returning a
pointer to an array of int.
ITYM int (*((*p)(char*)))[];

In general, where the name in next to a "(" it declares a function,
not a pointer to one.

--
Ben.
Mar 13 '08 #4

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

Similar topics

83
by: Alexander Zatvornitskiy | last post by:
Hello All! I'am novice in python, and I find one very bad thing (from my point of view) in language. There is no keyword or syntax to declare variable, like 'var' in Pascal, or special syntax in...
19
by: Mark Johnson | last post by:
Oddly enough, in searching Google for web and ngs, I could find only a handful of articles on this problem. I wonder if it's one not typically encountered? I wanted to have three divs that could...
8
by: newmans | last post by:
Perhaps one of the experts can straighten me out on this point... In Bjarne Stroustrup's book 'The C++ Programming Language' 3rd Edition, section 4.9, indicates that typedef complex<short>...
3
by: Jason | last post by:
char * const * (*fn)(void); Seems rarther confusing to me, becuase of the way const can be used, like this: const char * a; /* pointer to const char */ char const * a; /* pointer to const...
10
by: Kobu | last post by:
My question is about the use and meaning of the terms "declaration" and "definition" as it pertains to the C language. I've read sources that mix the two up when talking about such things as...
25
by: venky | last post by:
Hi main() { int x; /* it declaration or defination??*/ }
4
by: nospam_timur | last post by:
Let's say I have two files, myfile.h and myfile.c: myfile.h: int myfunction(int x); myfile.c: #include "myfile.h"
9
by: Jess | last post by:
Hello, I was told that if I declare a static class constant like this: class A{ static const int x = 10; }; then the above statement is a declaration rather than a definition. As I've...
2
by: Alan | last post by:
Does a template class declaration, like template <class T> have to come immediately prior to the declaration of the function, e.g., T do_something (T something) { . . . } that uses it?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.