Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Elite19

What is the command line?

This topic is 5467 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

Hi, this should probably be in the beginners forum but here goes anyway. I am reading various documents about programming apps that read a file at start up and perform certain functions. The book I''m reading keeps refering to the command line. Eg, If the user runs program x with no command line arguments the program will exit. Is it some sort of initialization process or something? If someone could elaborate on command lines that would be a great help. Sorry if this sounds like a stupid question, Thanks

Share this post


Link to post
Share on other sites
Advertisement
the command line is the things you write after a program name
eg: tar -x -v -f archive.tar
that command runs the program "tar" with 4 command line arguments.

In your program, the command line arguments are defined as follow


#include <stdio.h>
int main(int argc, char *argv[])
{
// argc is the number of argument (including the executable)
// so with the example above it would be 5
// argv[0] is "tar"
// argv[1] is "-x"
// up to argv[argc - 1]
// if you want to list all command line arguments, simply do
int i;
for(i=0; i<argc; i++)
printf("argument #%d: %s\n", i, argv);

return 0;
}


[edited by - lemurion on October 8, 2003 12:06:02 PM]

Share this post


Link to post
Share on other sites

  • 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!