Toon posts:

[C++] Foutje in de code van C-taal

Pagina: 1
Acties:
  • 36 views sinds 30-01-2008

Verwijderd

Topicstarter
Dit is de code waar (een) foutje(s) is ingeslopen.
-----------------------------------------------------------------
#define PRINTDRIVER
#include <windows.h>
#include <string.h>
#include <print.h>
#include <stdio.h>
int PrintHPFile(char *filename);
int main(void)
{

FILE *bestand;
bestand = fopen ("bes5.txt","w+");
PrintHPFile(bestand);
return 0;
}

int PrintHPFile(char *filename )
{
char *pszPrInfo = new char[ 80 ];

// Get the printer setup string from the ini file
GetProfileString( "windows", "device", ",,,", pszPrInfo, 80 );

// Format of ini file line = <Device,Driver,Port>
char *pszDevice = strtok( pszPrInfo, "," );
char *pszDriver = strtok( NULL, "," );
char *pszPort = strtok( NULL, "," );

// create a printer device context
HDC PrintHandle = CreateDC( pszDriver, pszDevice, pszPort,
NULL );

// get a job handle, allocate a buffer
HPJOB PrintJob;
char *buf = new char[ 1024 ];

// open the file for reading
FILE *hp_file = fopen( filename, "rb" );

// Start the print job
PrintJob = OpenJob( pszPort, filename, (HPJOB)PrintHandle );
StartSpoolPage( PrintJob );

// print the file, 1K at a time
for( size_t i(0);; )
{
i = fread( buf, 1, 1023, hp_file );
if( i>0 )
WriteSpool( PrintJob, buf, i );
else
break;
}

// Close up print job
EndSpoolPage( PrintJob );
CloseJob( PrintJob );

// Clean up
DeleteDC( PrintHandle );
fclose( hp_file );
delete[] pszPrInfo;
delete[] buf;
return 1;
}

Dit zijn mijn problemen:

1) print.cpp 13 : cannot convert 'FILE *' to 'char *' in function main
2) print.cpp 13 : type mismatch in parameter 'filename' in call to 'PrintHPFile(char *)' in function main()


Thx op voorhand

waxxie

  • whoami
  • Registratie: December 2000
  • Laatst online: 20:40
Verwacht nu niet dat wij het voor jou gaan oplossen hé

https://fgheysels.github.io/


  • gorgi_19
  • Registratie: Mei 2002
  • Laatst online: 18:52

gorgi_19

Kruimeltjes zijn weer op :9

Zie whoami, debuggen mag je zelf doen :)

Zie:
P&W FAQ - De "quickstart"
P&W FAQ - Leer **** debuggen!!

Digitaal onderwijsmateriaal, leermateriaal voor hbo


Dit topic is gesloten.