473,396 Members | 2,014 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,396 software developers and data experts.

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

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
4 1571
On 17 Oct, 10:24, "ian...@gmail.com" <ian...@gmail.comwrote:
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?

this looks like homework to me...
--
Nick Keighley

Oct 17 '07 #2
Nick Keighley wrote:
On 17 Oct, 10:24, "ian...@gmail.com" <ian...@gmail.comwrote:
>I have a struct defined thus:

typedef struct myStruct
{
int j;

} myStruct;

I saw somewhere calls with the following syntax:
f1(&*a)
[To the OP] Really? Where? What do you think it will do?
this looks like homework to me...
It looks like bovine excrement to me.
Oct 17 '07 #3
struct name { /* ... */ };

ret f(struct name *);

struct name obj1, *obj2, obj3[1], **obj4;
f(&obj);
f(obj2);
f(obj3);
f(*obj4);

Etc.

`&*p' == `&p[0]'

Oct 17 '07 #4
On Wed, 17 Oct 2007 09:24:50 -0000, "ia****@gmail.com"
<ia****@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)
It would help if we new what a was.

What do you think the effect of the combined & and * operators is? For
extra points, would it make a difference if the operators were
reversed? What is the only possible type the expression &*a (or *&a)
can have (on those occasions when it is a legal expression)?
>
What should be the protype of f1 so that it will be correct and
so that compilation will succeed ?
The prototype is not the problem.
>
I am talking about two cases:
In the first, we have the following definition:
myStruct a;
What happens when you apply the * operator to a struct?
>
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 ?
While passing an incompatible type to a function possibly could be
"corrected" by changing the prototype, what makes you think a
prototype can magically correct a syntax error?

Again, what happens when you apply the * operator to a struct?
>
Any ideas?
Yes. Make a note of the author who wrote the call to f1. Then make
sure you never again take anything written by him seriously.
Remove del for email
Oct 19 '07 #5

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

Similar topics

28
by: David MacQuigg | last post by:
I'm concerned that with all the focus on obj$func binding, &closures, and other not-so-pretty details of Prothon, that we are missing what is really good - the simplification of classes. There are...
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...
8
by: Robert | last post by:
Hi, I can use "with" like this: function MyObject(message) { this.message = message; } function _MyObject_speak() {
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...
5
by: noblesantosh | last post by:
Hi all, What is the difference between following two function definations? <1> void func(void) { /* some code */ } <2> void func()
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
92
by: Heinrich Pumpernickel | last post by:
what does this warning mean ? #include <stdio.h> int main() { long l = 100; printf("l is %li\n", l * 10L);
4
by: Ty | last post by:
Hello all, I am creating a web site with Visual Stuido 2008. I am trying to use a java script file to create a busybox for login from this page http://blogs.crsw.com/mark/articles/642.aspx. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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,...

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.