Mail Archives: djgpp/2000/01/19/14:52:26
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 -