Mail Archives: djgpp/1997/03/12/06:02:58
Hello.
I have written a fairly simple program to translate TGA files to
PCX files using allegro. It crashes. Here is my source code.
-----------------------------------------------------------------------------------
#include <allegro.h>
#include <string.h>
#include <iostream.h>
#include <dir.h>
#include <dos.h>
int main(int argc, char *argv[])
{
char infile[13];
char outfile[13];
ffblk fileinfo;
PALETTE pal;
BITMAP *bitin;
if(argc != 3) // check the command line arguments.
{
cout << "wrong number of args.";
return 0;
}
strcpy(infile, argv[1]); // copy the arguments into the file name
strings
strcpy(outfile, argv[2]);
if(findfirst(infile, &fileinfo, 0)) // make sure that the infile exists!
{
cout << "\nFile does not exist, or is a hidden or system file\n";
return 0;
}
bitin = load_tga(infile, pal); // load the TGA file
save_pcx(outfile, bitin, pal); // save it as a pcx file
}
--------------------------------------------------------------------------------------
This is the command line I used to compile it.
9:32p c:\gnu\bin>gcc -g -o trans trans.cpp -lalleg -lgpp -lc
This is the dump(symified) that is printed out after I run the program
9:33p c:\gnu\bin>trans out.tga out.pcx
Exiting due to signal SIGSEGV
Page fault at eip=00002c5a, error=0004
eax=00000000 ebx=00085000 ecx=00000000 edx=00031c00 esi=00030d70
edi=000381e0
ebp=000781b8 esp=00077c2c cs=00a7 ds=00af es=00af fs=008f gs=00bf ss=00af
Call frame traceback EIPs:
0x00002c5a _save_pcx+254
0x00021c87 ___crt1_startup+115
I have no idea what is causing this. I'm guessing it's something silly I
did wrong because
I have had no trouble with any of these functions in the past when they
were used by
themselves. (although this is the first time I've used load_tga);
out.tga is a file that exists in the current directory.
It was created by Polyray version 1.6
Any responses/answers/flames/questions/donations appreciated.
TIA
|| Fwec AT juno DOT com
||
|| "Why can they make a potato chip in one second, but it takes us months
to
|| develop software?" - Dilbert's Boss
||
- Raw text -