473,694 Members | 2,895 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How many levels of pointers can you have?

This question is occur in interview. Please help me.

Jun 6 '07
158 9033
Kenneth Brody wrote:
Ben Pfaff wrote:
>>
madhawi <ma*******@gmai l.comwrites:
Subject: How many levels of pointers can you have?

This question is occur in interview. Please help me.

Twelve:

"At least 12."
> 5.2.4.1 Translation limits
1 The implementation shall be able to translate and execute at
least one program that contains at least one instance of
every one of the following limits:13)
[...]
- 12 pointer, array, and function declarators (in any
combinations) modifying an arithmetic, structure, union,
or incomplete type in a declaration

Now _there's_ a question for the standards committee... Where did
they pick the number 12 from?
Maybe all the compilers allowed "as many as you like (until we
run out of store)", except one that had a 4-bit field for
"number of indirections" in a type with the top three values
reserved for "struct", "union", or "function pointer".

--
Speculative Faction Hedgehog
Otherface: Jena RDF/Owl toolkit http://jena.sourceforge.net/

Jun 6 '07 #11
Kenneth Brody wrote:
Now _there's_ a question for the standards committee... Where did
they pick the number 12 from?
from C89

--
Tor <torust [at] online [dot] no>

Jun 6 '07 #12
Ben Pfaff wrote:
>
madhawi <ma*******@gmai l.comwrites:
Subject: How many levels of pointers can you have?

This question is occur in interview. Please help me.

Twelve:
/* BEGIN new.c */

#include <stdio.h>

int main(void)
{
(************pu ts)("Cool!!!");
return 0;
}

/* END new.c */

--
pete
Jun 6 '07 #13
In article <4c************ *******@fe2.new s.blueyonder.co .uk>,
Chris Dollin <eh@electriched gehog.netwrote:
>Kenneth Brody wrote:
>Ben Pfaff wrote:
>>>
madhawi <ma*******@gmai l.comwrites:

Subject: How many levels of pointers can you have?

This question is occur in interview. Please help me.

Twelve:

"At least 12."
>> 5.2.4.1 Translation limits
1 The implementation shall be able to translate and execute at
least one program that contains at least one instance of
every one of the following limits:13)
[...]
- 12 pointer, array, and function declarators (in any
combinations) modifying an arithmetic, structure, union,
or incomplete type in a declaration

Now _there's_ a question for the standards committee... Where did
they pick the number 12 from?

Maybe all the compilers allowed "as many as you like (until we
run out of store)", except one that had a 4-bit field for
"number of indirections" in a type with the top three values
reserved for "struct", "union", or "function pointer".
I have a vague memory from many years back about what I believe was a
Honeywell mainframe (36 bit words, 18 bit addressing). One of the features
of this beast was indirect addressing where if a bit was set in a word
when it was accessed, it indicated that the word should be used as an
address pointing to where the actual parameter was. And if *that* had that
magic bit set, then it was also an address pointing to where the actual
parameter was. This indirection could in theory go quite a distance. However
the computer would throw an exception if too many levels of indirection
were being used. I don't remember how many levels this was.

But given that the above feature could be used to implement pointer to pointer
to ..... in a fairly efficient C implementation. I can see a "must be able
to do at least X levels of indirection" requirement based upon the limits
of the computers with this capability.

Now this is pure speculation, but I wouldn't be surprised if there exists
a modern computer that has this indirect capability and has a limit on
how many levels of indirection it's willing to perform without causing
an exception.
Jun 6 '07 #14
In article <f4***********@ smof.fiawol.org >,
John Cochran <jd*@smof.fiawo l.orgwrote:
>I have a vague memory from many years back about what I believe was a
Honeywell mainframe (36 bit words, 18 bit addressing). One of the features
of this beast was indirect addressing where if a bit was set in a word
when it was accessed, it indicated that the word should be used as an
address pointing to where the actual parameter was. And if *that* had that
magic bit set, then it was also an address pointing to where the actual
parameter was. This indirection could in theory go quite a distance. However
the computer would throw an exception if too many levels of indirection
were being used. I don't remember how many levels this was.

But given that the above feature could be used to implement pointer to pointer
to ..... in a fairly efficient C implementation. I can see a "must be able
to do at least X levels of indirection" requirement based upon the limits
of the computers with this capability.
I doubt C has ever been implemented on that architecture by setting
the relevant bit in pointers. If we have char *****p, then both **p
and ****p are legal expressions: the number of dereferences is
controlled by the program, not the data. C doesn't have a
"dereferenc e as much as you can" operator.
>Now this is pure speculation, but I wouldn't be surprised if there exists
a modern computer that has this indirect capability and has a limit on
how many levels of indirection it's willing to perform without causing
an exception.
I *would* be surprised if there was such a modern computer.

In any case, the limit in C89 - which is a limit on types, not
dereferencing of objects - most likely just reflects how some common
existing implementation handled declarations.

-- Richard

--
"Considerat ion shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Jun 6 '07 #15
Ben Pfaff <bl*@cs.stanfor d.eduwrites:
madhawi <ma*******@gmai l.comwrites:
>Subject: How many levels of pointers can you have?

This question is occur in interview. Please help me.

Twelve:

5.2.4.1 Translation limits
1 The implementation shall be able to translate and execute at
least one program that contains at least one instance of
every one of the following limits:13)
[...]
- 12 pointer, array, and function declarators (in any
combinations) modifying an arithmetic, structure, union,
or incomplete type in a declaration
Yes, but like all the limits in 5.2.4.1, it doesn't necessarily mean
very much. A conforming implementation is merely required to
translate and execute *one* program that hits all the listed limits.
Another program with 12 levels of pointers might fail to compile.

The point of the requirement, I think, is that the easiest way to
satisify it is not to have any fixed limits at all, by making the
relevant data structures within the compiler dynamic. A typical
compiler most likely won't complain about 13, or 20, or 99 levels of
pointers (unless it issues a warning).

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jun 6 '07 #16
On Jun 7, 8:49 am, "Kira" <a...@n.tkwrote :
I wonder if anybody ever made a non toy program with 12 levels of pointers.
Does this count? :)
http://groups.google.co.nz/group/alt...167ce376b99b14

Jun 6 '07 #17
Old Wolf said:
On Jun 7, 8:49 am, "Kira" <a...@n.tkwrote :
>I wonder if anybody ever made a non toy program with 12 levels of
pointers.

Does this count? :)
http://groups.google.co.nz/group/alt...167ce376b99b14
That was a pretty fun thread from top to bottom.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Jun 7 '07 #18
Kenneth Brody wrote:
Ben Pfaff wrote:
>madhawi <ma*******@gmai l.comwrites:
>>Subject: How many levels of pointers can you have?

This question is occur in interview. Please help me.

Twelve:

"At least 12."
> 5.2.4.1 Translation limits
1 The implementation shall be able to translate and execute at
least one program that contains at least one instance of
every one of the following limits:13)
[...]
- 12 pointer, array, and function declarators (in any
combinations) modifying an arithmetic, structure, union,
or incomplete type in a declaration

Now _there's_ a question for the standards committee... Where did
they pick the number 12 from?
I suspect a vote, about 20 years ago, long forgotten.

--
<http://www.cs.auckland .ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfoc us.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
<http://kadaitcha.cx/vista/dogsbreakfast/index.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com

Jun 7 '07 #19
On Wed, 06 Jun 2007 15:59:57 -0400, Kenneth Brody
<ke******@spamc op.netwrote:
>Now _there's_ a question for the standards committee... Where did
they pick the number 12 from?
I think they just doubled the 6 guaranteed by K&R. Studies showed
that some complicated code used 6 or more indirections but that
virtually no code used more than 10.

George
--
for email reply remove "/" from address
Jun 7 '07 #20

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

Similar topics

6
13717
by: Angus | last post by:
I am using a global which is a void* I have it defined in one file as: void* hFlag; and one other header file as: extern void* hFlag; But I get this compile error:
0
8552
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8971
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8818
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8812
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6481
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4332
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2992
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2249
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1970
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.