What should be the prototype of this function ? (noobie)

I

ianbrn

Hello,
I have a struct defined thus:

typedef struct myStruct
{
int j;
} myStruct;

I saw somewhere calls with the following syntax:
f1(&*a)

What should be the protype of f1 so that it will be correct and
so that compilation will succeed ?

I am talking about two cases:
In the first, we have the following definition:
myStruct a;

in the second, we have
myStruct* a;

Is it possible with both case to have a definition of f1() so that
f1(&*a) will be correct and pass compilation ?

Any ideas?

Ian
 
I

Ivanna Pee

Hello,
I have a struct defined thus:

typedef struct myStruct
{
int j;

} myStruct;

I saw somewhere calls with the following syntax:
f1(&*a)

What should be the protype of f1 so that it will be correct and
so that compilation will succeed ?

I am talking about two cases:
In the first, we have the following definition:
myStruct a;

in the second, we have
myStruct* a;

Is it possible with both case to have a definition of f1() so that
f1(&*a) will be correct and pass compilation ?

Any ideas?

Ian

void WinWriteMyProgramForMe(void);
 
I

Ivanna Pee

Hello,
I have a struct defined thus:

typedef struct myStruct
{
int j;

} myStruct;

I saw somewhere calls with the following syntax:
f1(&*a)

What should be the protype of f1 so that it will be correct and
so that compilation will succeed ?

I am talking about two cases:
In the first, we have the following definition:
myStruct a;

in the second, we have
myStruct* a;

Is it possible with both case to have a definition of f1() so that
f1(&*a) will be correct and pass compilation ?

Any ideas?

Ian

void WinWriteMyProgramForMe(void);
 
V

vipvipvipvip.ru

Even if it IS homework, I can think of no better place than to ask
here. It is, after all, a C group dedicated to helping people. Or so I
thought.
You are correct, i apologise.
What should be the protype of f1 so that it will be correct and
so that compilation will succeed ?
If you're worried only for the compilation, just cast it.
Anyway, here is some code that does what you ask for.

type f1(myStruct *);
/* ... */
int main(void) {
myStruct obj = { 0 };
myStruct *ptr = &obj;
f1(&obj);
f1(ptr);
f1(&*ptr);
f1(*&ptr);
f1(&ptr[0]);
f1(&0[ptr]);
}
 
B

Barry Schwarz


You posted the same question two hours ago under a different subject
(one letter different). This is not a chat room, you need to give
your message time to propagate and others time to respond. Now go
look at the responses to your original.


Remove del for email
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top