c cgi ÏÂÔØÎļþ - C/C++ / CÓïÑÔ
C/C++ code:
#include <stddef.h>
#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>
#include <stdlib.h>
#include <string.h>
char *GetFileString(const char *path, long *fl)
{
char *buf = NULL;
FILE *cfPtr = fopen(path, "rb");
struct stat st;
*fl = 0;
if (cfPtr!=NULL)
{
fstat(fileno(cfPtr), &st);
*fl = st.st_size;
buf = (char *)malloc((*fl+1)*sizeof(char));
memset(buf, 0x0, *fl+1);
fread(buf, *fl, 1, cfPtr);
fclose(cfPtr);
}
return(buf);
}
int main(int argc, char *argv[])
{
long pl;
char *p;
printf("Content-Type: application/pdf\n");
printf("Content-Disposition: attachment; filename=DOWNLOAD.pdf\n\n");
p = GetFileString("C:\\pdf1.pdf", &pl);
if (pl>0)
{
_setmode(fileno(stdout), O_BINARY);
fwrite(p, pl, 1, stdout);
free(p);
}
return(0);
}
download.c: In function `GetFileString':
download.c:42: storage size of `st' isn't known
download.c: In function `main':
download.c:65: `O_BINARY' undeclared (first use in this function)
download.c:65: (Each undeclared i
Ïà¹ØÎÊ´ð£º
ÓÐÒ»10*10¾ØÕ󣬳ýÈ¥µÚÒ»¸öµã£¨0£¬0£©ºÍ×îºóÒ»µã£¨9£¬9£©£¬»¹Óа˸öµãΪ1£¬ÆäËû¶¼Îª0£¬ÒªÇóÓöþάÊý×é±íʾ¡£°Ë¸öµãÊÇËæ»úÉú³ÉµÄ£¬±àдÏà¹Ø³ÌÐò±íʾ¾ØÕóËùÓпÉÄÜÇé¿ö¡£
ÕæÐÄÇó½Ì¸÷λ¸ßÊÖ£¬°¥£¡±¾ÈËÌ«²ËÁË£¡ºÇºÇ£¡
......
ΪʲôÎҵijÌÐòµ÷ÓÃXMLÅäÖÃÎļþÖеİ¢À²®ÎÄÏÔʾ²»³öÀ´£¿ÆäËûµÄÓïÖÖ¶¼¿ÉÒÔ£¬ÈçÖÐÎÄ£¬Ó¢ÎÄ£¬µÂÎͼ¿É¡£
ÎÒ½«XMLµÄ±àÂë¸ÄΪutf-8ºÍunicodeµÄµ½µÃ½á¹û¶¼Ò»Ñù.
°¢À²®ÎĵÄ×Ö¿âÄãÓÐô£¿
ÓÐ,ÎÒµÄEXEÊÇ·ÅÔÚpc»úÉÏÖ´Ðе ......
ÈçºÎ½«Ò»¸öListBoxÖеÄÊý¾Ý´æÔÚÊý¾Ý¿âÖеÄÒ»¸ö×Ö¶ÎÏÂÃæ£¬²¢ÇÒÿÌõ¼Ç¼µÄ×Ö·û´®¸öÊý²»Ò»¶¨ ÒÔ¼°ÈçºÎ´ÓÊý¾Ý¿âÖжÁÈ¡¸ÃListBoxÖеÄËùÓмǼ
C/C++ code:
//´æÈëÊý¾Ý¿â
void __fastcall TForm1::Button5Click(TO ......