473,507 Members | 2,395 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Answer to question 4.8 from the FAQ

Hello,

In the answer to question 4.8 I see this code (copied and pasted):

-------------------------
void f(ipp)
int **ipp;
{
static int dummy = 5;
*ipp = &dummy;
}
....

int *ip;
f(&ip);
-------------------------

I'm confused about the two first lines. Should'nt the first one be
written 'void f(**ipp)' and the second one scrapped altogether?

If not, I don't understand how the above can be legal.

JFL
--
Jean-François Lemaire
Jan 4 '08 #1
4 1249
Jean-François Lemaire wrote:
Hello,

In the answer to question 4.8 I see this code (copied and pasted):

-------------------------
void f(ipp)
int **ipp;
{
static int dummy = 5;
*ipp = &dummy;
}
...

int *ip;
f(&ip);
-------------------------

I'm confused about the two first lines. Should'nt the first one be
written 'void f(**ipp)' and the second one scrapped altogether?
ITYM `void f(int **ipp)'.
If not, I don't understand how the above can be legal.
Question 11.3 has a useful hint, and 11.4 is worth
a look, too.

--
Er*********@sun.com

Jan 4 '08 #2
On Friday 4 January 2008 17:28, Eric Sosman wrote:
Jean-François Lemaire wrote:
>In the answer to question 4.8 I see this code (copied and pasted):

-------------------------
void f(ipp)
int **ipp;
{
static int dummy = 5;
*ipp = &dummy;
}
...

int *ip;
f(&ip);
-------------------------

I'm confused about the two first lines. Should'nt the first one be
written 'void f(**ipp)' and the second one scrapped altogether?

ITYM `void f(int **ipp)'.
IID (Indeed I Did).
>If not, I don't understand how the above can be legal.

Question 11.3 has a useful hint, and 11.4 is worth
a look, too.
OK, I understand now. I'm not used to reading the old style syntax and
would have never thought it was simply that.

Thanks for pointing me in the right direction.

JFL
--
Jean-François Lemaire
Jan 4 '08 #3
Jean-Francois Lemaire <jf*******@skynet.bewrites:
In the answer to question 4.8 I see this code (copied and pasted):

-------------------------
void f(ipp)
int **ipp;
{
static int dummy = 5;
*ipp = &dummy;
}
[...]

That's an old-style function definition; it predates the ANSI
standard, but it's still permitted, even in C99.

What I don't know is why the FAQ still uses it here. I see no good
reason not to use a prototype. Probably it's just an oversight. I've
sent e-mail to Steve Summit.

(Sorry about mangling your name; this environment isn't handling
non-ASCII characters very well.)

--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
[...]
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jan 4 '08 #4
On Friday 4 January 2008 21:26, Keith Thompson wrote:
Jean-Francois Lemaire <jf*******@skynet.bewrites:
>In the answer to question 4.8 I see this code (copied and pasted):

-------------------------
void f(ipp)
int **ipp;
{
static int dummy = 5;
*ipp = &dummy;
}
[...]

That's an old-style function definition; it predates the ANSI
standard, but it's still permitted, even in C99.

What I don't know is why the FAQ still uses it here. I see no good
reason not to use a prototype. Probably it's just an oversight. I've
sent e-mail to Steve Summit.
Yes, this can be confusing for new users of the language, the intended
audience of the FAQ, who are less likely to have encountered such a
function definition. At least it was confusing for me.
(Sorry about mangling your name; this environment isn't handling
non-ASCII characters very well.)
No excuse needed, I can assure you.

JFL
--
Jean-François Lemaire
Jan 4 '08 #5

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

Similar topics

3
5180
by: Mohammed Mazid | last post by:
Hi folks! Can anyone please help me with this? I am developing a Quiz program but I am stuck with "multiple answers". Basically I need some sort of code that would select multiple answers...
4
3591
by: Mohammed Mazid | last post by:
Hi folks! Can anyone please help me with this? I am developing a Quiz program but I am stuck with "multiple answers". Basically I need some sort of code that would select multiple answers...
9
3734
by: Dave H | last post by:
Hello, I have a query regarding definition lists. Is it good practice semantically to use the dt and dd elements to mark up questions and answers in a frequently asked questions list, or FAQ? ...
4
3022
by: Nigel Molesworth | last post by:
I've Googled, but can't find what I need, perhaps I asking the wrong question! I want a "FAQ" page on a web site, I hate those pages that scroll you to the answer so and I figured that a good...
2
1960
by: amelia170 | last post by:
I am creating a database with a yes or no answer for question 1. Based on that answer, (if they answer yes) they will answer question 2, then three....However, if they answer no to question one, I...
32
9399
by: Michael C | last post by:
I want to inherit from Bitmap to add a property but I can't because it's sealed. Is there any reason to seal a class? Thanks, Michael
0
832
by: Ryan | last post by:
Although I would like my application to require Question and Answer, I plan to allow a central administrator to create accounts and then require users to setup their Question/Answer the first time...
2
6835
by: Jonathan Wood | last post by:
In my application, new accounts must be created by an administrator--users will not create their own. Ideally, the user could then log on and specify their own password question and answer, and the...
2
7646
by: Ken Fine | last post by:
I want to add the security question and answer security feature to the ChangePassword control. I am aware that this functionality is built into the PasswordRecovery tool. I have implemented the...
0
7111
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
7376
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
7031
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
7485
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
5623
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
5042
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
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
760
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
412
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.