473,387 Members | 1,749 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,387 software developers and data experts.

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

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

Oct 17 '07 #1
6 1198
http://groups.google.com/group/comp....e8f5b02ac3da7/
If you don't like the answers given here, consider another newsgroup.

Oct 17 '07 #2
vi*************@gmail.com writes:
http://groups.google.com/group/comp....e8f5b02ac3da7/
If you don't like the answers given here, consider another newsgroup.
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.

As for the "excrement" comment, well, some posters seem to be losing the
plot.

Oct 17 '07 #3
On Oct 17, 10:13 am, "ian...@gmail.com" <ian...@gmail.comwrote:
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);

Oct 17 '07 #4
On Oct 17, 10:13 am, "ian...@gmail.com" <ian...@gmail.comwrote:
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);

Oct 17 '07 #5
On Oct 17, 6:40 pm, Richard <rgr...@gmail.comwrote:
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]);
}
Oct 17 '07 #6
On Wed, 17 Oct 2007 14:13:05 -0000, "ia****@gmail.com"
<ia****@gmail.comwrote:
>Hello,
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
Oct 19 '07 #7

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

Similar topics

8
by: Elf M. Sternberg | last post by:
One of the complaints about prototype.js (google for it if you're not familiar with it) is that it's poorly documented. I have this inkling that the key to understanding prototype.js is in the...
21
by: Rob Somers | last post by:
Hey people, I read a good thread on here regarding the reason why we use function prototypes, and it answered most of my questions, but I wanted to double check on a couple of things, as I am...
9
by: pamelafluente | last post by:
Hi, I was "studying" the famous (public code) BusyBox. I see the instruction: var busyBox = new BusyBox as in var busyBox = new BusyBox("BusyBox1", "busyBox", 4, "gears_ani_", ".gif",...
5
by: Daz | last post by:
Hi everyone. My query is very straight forward (I think). What's the difference between someFunc.blah = function(){ ; } and
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...

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.