954,480 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

File handling

void openfile(char *,FILE**)
what does double stars indicates

seemant_sun
Newbie Poster
13 posts since May 2009
Reputation Points: 18
Solved Threads: 1
 
void openfile(char *,FILE**) what does double stars indicates


The second argument type is a pointer to a pointer to FILE type.
Didn't you understand what's a pointer?
Evidently this function returns FILE* pointer via this argument. What's a strange perversion...

ArkM
Postaholic
2,001 posts since Jul 2008
Reputation Points: 1,234
Solved Threads: 348
 

Well, it has one advantage over a return value -- you have to pass in an address, whereas you could ignore a return value. :) I don't think that's how I would write it, though.

dwks
Posting Whiz in Training
269 posts since Nov 2005
Reputation Points: 185
Solved Threads: 28
 

>>you have to pass in an address

Not if you pass NULL.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

How many times a pointer operator can appear with pointer to pointer declaration.

int a;
  int *p;
  int **q;
  int ***r;
  int ****s;
  ....

   p=&a;
   q=&p;
   r=&q;
   s=&r;
   ...

Is there any limit imposed by ANSI?

__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 

That's it:
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:
...
- 12 pointer, array, and function declarators (in any combinations) modifying an arithmetic, structure, union, or incomplete type in a declaration
...
Implementations should avoid imposing fixed translation limits whenever possible.
(256 in C++)

ArkM
Postaholic
2,001 posts since Jul 2008
Reputation Points: 1,234
Solved Threads: 348
 

Isn't 16 *'s maximum in C ???
I mean that *p,**p,***p.....

csurfer
Posting Pro
568 posts since Jan 2009
Reputation Points: 485
Solved Threads: 88
 

With VC++ 2008 Express, compiling a C program, I was able to compile char*(500 stars) ptr = "Hello"; before the parser complained. And then the error message was "parser stack overflow, program too complex"

Interestingly, as a c++ program I was able to give it about 920 stars before the compiler crapped out -- then it was during the link stage, not the compile stage.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

curious, did you incrementally compile 1 additional indirection operator each time? did you use a scripting language to do it?

jephthah
Posting Maven
2,587 posts since Feb 2008
Reputation Points: 2,143
Solved Threads: 179
 

>Isn't 16 *'s maximum in C ???
I have never seen maximal values of translation limits were defined in C docs.

ArkM
Postaholic
2,001 posts since Jul 2008
Reputation Points: 1,234
Solved Threads: 348
 
>Isn't 16 *'s maximum in C ??? I have never seen maximal values of translation limits were defined in C docs.


Well I had seen it being limited in some early versions of cc gcc and all .Actually had read about them somewhere "Not quite sure though".So asked it here.But don't know how Ancient Dragon found out the limit,but 500 and 920 are quite surprising !!!

@Ancient Dragon : Can I get the link where you found that out ? Or atleast the method ? And what do you think is the limit for POSIX and C99 compliant gcc version?

csurfer
Posting Pro
568 posts since Jan 2009
Reputation Points: 485
Solved Threads: 88
 

>Well I had seen it being limited in some early versions of cc gcc and all.
It was not the C language limit, it's a limit of the compiler (implementation),
>...Or atleast the method...
Generate a probe module by a simplest program in C then use binary search ;)

ArkM
Postaholic
2,001 posts since Jul 2008
Reputation Points: 1,234
Solved Threads: 348
 

The way I found out the limits was to write a program that had a pointer with a bunch of stars.

>>did you incrementally compile 1 additional indirection operator each time?

Suuuure I did, and compiled it over 900 times just for this thread. And if you believe that I have some stocks in the Golden Gate Bridge I'll sell you :)

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

The way I found out the limits was to write a program that had a pointer with a bunch of stars.

>>did you incrementally compile 1 additional indirection operator each time?

Suuuure I did, and compiled it over 900 times just for this thread. And if you believe that I have some stocks in the Golden Gate Bridge I'll sell you :)

um, well, it would a fairly trivial matter to do so using Perl or some other scripting language. but i agree with you that we have better ways to spend our time.

just what i was wondering is along the lines of "hey great, so 900 stars fails..." but does 850? or 800? or 500? or 100?

IOW, where'd you get your magic number of 900?


.

jephthah
Posting Maven
2,587 posts since Feb 2008
Reputation Points: 2,143
Solved Threads: 179
 

>>IOW, where'd you get your magic number of 900?

trial and error. It was actually about 912. Held down the star key until 900+ stars appeared then tried to compile. When the compiler crapped out I backed out a few stars until I got a clean compile/link. My guess is that the compiler pushes something on the stack for each star.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You