Cannot convert 'char far*' to 'const char *'?
-
Basically what I'm trying to do is to compile a PCX loader and I can't seem to get around this error. Here is the full code of this thing: #include <stdio.h> #include <dos.h> #include <io.h> #include <fcntl.h> #include <mem.h> #include "pcx.h" const unsigned int IMAGE_SIZE=64000u; // Size of PCX bitmap // Pcx class destructor Pcx::~Pcx() { // if pointers have changed from initial 0 // then release memory if( image) delete [] image; } int Pcx::Load(char far *filename) { // Function to load PCX data from file FILENAME // Open file; return nonzero value on error if ((infile=open(filename,O_BINARY))==-1) return(-1); // Move file pointer to start of header: lseek(infile,0L,SEEK_SET); // Reader header from PCX file: read(infile,&header, sizeof(pcx_heade… // The PCX class is now reuseable. If there is already an image there // release it... if( image != 0) delete [] image; image = 0; // Decompress bitmap and place in buffer, // returning non-zero value if error occurs: if (load_image()) return(-1); // Decompress palette and store in array: load_palette(); close(infile); // Close PCX file return(0); // Return non-error condition } // Decompress bitmap and store in buffer int Pcx::load_image() { // Symbolic constants for encoding modes, with // BYTEMODE representing uncompressed byte mode // and RUNMODE representing run-length encoding mode: const int BYTEMODE=0, RUNMODE=1; // Buffer for data read from disk: const int BUFLEN=5*1024; int mode=BYTEMODE; // Current encoding mode being used, // initially set to BYTEMODE int readlen; // Number of characters read from file static unsigned char outbyte; // Next byte for buffer static unsigned char bytecount; // Counter for runs static unsigned char buffer[BUFLEN]; // Disk read buffer // Allocate memory for bitmap buffer and return -1 if // an error occurs: if ((image=new unsigned char[IMAGE_SIZE])==0) return(-1); int bufptr=0; // Point to start of buffer readlen=0; // Zero characters read so far // position file to offset for reading image lseek(infile,128L,SEEK_SET); // Create pointer to start of image: unsigned char *image_ptr=image; // Loop for entire length of bitmap buffer: for (long i=0; i<IMAGE_SIZE; i++) { if (mode==BYTEMODE) { // If we're in individual byte // mode.... if (bufptr>=readlen) { // If past end of buffer... bufptr=0; // Point to start // Read more bytes from file into buffer; // if no more bytes left, break out of loop if ((readlen=read(infile,buffer,BUFLEN))==0… break; } outbyte=buffer[bufptr++]; // Next byte of bitmap if (outbyte>0xbf) { // If run-length flag... // Calculate number of bytes in run: bytecount = (int)((int)outbyte & 0x3f); if (bufptr>=readlen) { // If past end of buffer bufptr=0; // Point to start // Read more bytes from file into buffer; // if no more bytes left, break out of loop if ((readlen=read(infile,buffer,BUFLEN))==0… break; } outbyte=buffer[bufptr++]; // Next byte of bitmap // Switch to run-length mode: if (--bytecount > 0) mode = RUNMODE; } } // Switch to individual byte mode: else if (--bytecount == 0) mode=BYTEMODE; // Add next byte to bitmap buffer: *image_ptr++=outbyte; } return 0; } void Pcx::load_palette() // Load color register values from file into palette array { // Seek to start of palette, which is always 768 bytes // from end of file: lseek(infile,-768L,SEEK_END); // Read all 768 bytes of palette into array: unsigned char *ptr = Palette(); read(infile,ptr ,3*256); // Adjust for required bit shift: for (int i=0; i<3*256; i++, ptr++) *ptr >>= 2; } I'm also getting a "Type mismatch in parameter '__path in call to 'open(const char *,int,...)'" on top of that. Any suggestions?
-
Answer:
I don't know what a far is, but here is how you convert: void myfunc(void *a) { char *c = (char *) a ; printf("%s", c) ; }
Doomguy at Yahoo! Answers Visit the source
Related Q & A:
- How to convert a char array into an int in C++?Best solution by Stack Overflow
- How to convert from string to char in C++?Best solution by Stack Overflow
- Converting char array to double in C?Best solution by stackoverflow.com
- How to pass char** in python ctype?Best solution by Stack Overflow
- What is the most fiscally far left, socially far left political party in the United States?Best solution by pewresearch.org
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.