Jump to content
  • Advertisement
Sign in to follow this  
TEUTON

what do you say??

This topic is 4526 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

can we write int main(int argc, char *********argv){} Does standard say anything about this??? Can we add number of stars??

Share this post


Link to post
Share on other sites
Advertisement
You can't write that since it would mean an empty function main taken two parameters, parameter one being of type int and parameter two being of type pointer to pointer to pointer to pointer to pointer to pointer to pointer to pointer to pointer to char. What did you expect argv to be?

Share this post


Link to post
Share on other sites
I guess standard says we can have only two forms

char **argv and char*argv[]

Isn't it??

Share this post


Link to post
Share on other sites
Quote:
Original post by TEUTON
can we write

int main(int argc, char *********argv){}

Does standard say anything about this??? Can we add number of stars??


You can not in the main signature write any number of stars. It's always two:


int main(int arg_c, char * argv[]);


or


int main(int arg_c, char ** argv);


But in your own functions you can have as many indirections as you want.

Share this post


Link to post
Share on other sites
Quote:
Original post by TEUTON
I guess standard says we can have only two forms

char **argv and char*argv[]

Isn't it??


The standard says the following (3.6.1):

Quote:
An implementation shall not predefine the main function. This function shall not be overloaded. It shall have a return type of type int, but otherwise its type is implementation-defined. All implementations shall allow both of the following definitions of main:
int main() { /* ... */ }
and
int main(int argc, char* argv[]) { /* ... */ }
In the latter form argc shall be the number of arguments passed to the program from the environment in which the program is run. If argc is nonzero these arguments shall be supplied in argv[0] through argv[argc-1] as pointers to the initial characters of null-terminated multibyte strings (NTMBSs) (17.3.2.1.3.2) and argv[0] shall be the pointer to the initial character of a NTMBS that represents the name used to invoke the program or "". The value of argc shall be nonnegative. The value of argv[argc] shall be 0.


Which basicly means that in theory a compiler would be allowed to provide a main function like the one in your original post, but it's only required to have:
int main()
and
int main(int argc, char* argv[])

Share this post


Link to post
Share on other sites
You can do it generally. But it's not going to be much good. After all, the operating system is going to give you data that's char**, so if you try and use it as char************, you'll GPF.

Share this post


Link to post
Share on other sites
You certainly can do it. The question is why you would do it.

I haven't found a need for more than 3rd order indirection (char ***omg;). Even at this level its getting quite hard to grasp my mind around it (I think I tried fourth order for a few minutes but really didn't need to).

Really when it comes down to it, do you really need more than a 3 dimensional array? Anything more is just going to screw with your head.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!