delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/01/19/14:52:26

From: Mark Cowan <mark DOT cowan AT studentmail DOT newcastle DOT edu DOT au>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Quick Question!
Date: Thu, 20 Jan 2000 03:51:03 -0800
Organization: The University of Newcastle
Lines: 60
Message-ID: <3886F6A6.6EE516E3@studentmail.newcastle.edu.au>
References: <38852C78 DOT 46CF4D95 AT sympatico DOT ca>
NNTP-Posting-Host: c52h1-asy56.newcastle.edu.au
Mime-Version: 1.0
X-Mailer: Mozilla 4.7 [en] (Win98; I)
X-Accept-Language: en
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Brad,

To explain the parts of the "blurb" you are interested in:

int main(int argc, char *argv[])

-        This line of code allows the main program to take command line
arguments
            eg
        myprog.exe Hello All
        would leave argv[ 0 ] point to char array of myprog.exe
                           argv[ 1 ]     "     "    "      "       "
Hello
                           argb[ 2 ]     "     "    "      "       "
All
        and argc = 3

if (argc != 2)

-  this line in the program checks that there were only two arguments
given on command line
eg ex15 mypiccy.bmp as is the usage for this program
    Thus if there are not two command line arguments (including the
program name) it will not run the program,  just give you usage

Hope this helps,

Mark
--
_____________________________________________

Mark Cowan
Newcastle Australia


BRAD MURPHY wrote:

>   Hi, I was wondering if somebody could please
> help me by explaining the following blurb of code.
>
> int main(int argc, char *argv[])
> {
>    BITMAP *the_image;
>    PALLETE the_pallete;
>
>    if (argc != 2) {
>       printf("Usage: 'ex15 filename.[bmp|lbm|pcx|tga]'\n");
>       return 1;
>    }
> (This is from the allegro example ex15.c)
>   I am trying to learn how to load and display a bitmap, but
> I can't get this example to work for me, and it has to do
> with the above code.  There is of course more code, but
> when I run the executable, the program ends immediately
> with the above printf's statement!
>
> Thank you to anybody who offers help.
>
> B.Murphy

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019