c/vc++ »·¾³Ï²»Í¬µÄÎļþ³¤¶È»ñÈ¡·½·¨
£¨Ò»£©
¶ÔÎļþ²Ù×÷ʱÓÐʱ»ñµÃÎļþµÄ´óСʱ±ØÒªµÄ.ÏÂÃæÊÇ»ñµÃÆä´óССµÄ½Ï¼òµ¥·½·¨.
#include<io.h> //CÓïÑÔÍ·Îļþ
#include<iostream> //for system();
using namespace std;
int main()
{
int handle;
handle = open("test.txt", 0x0100); //open file for read
long length = filelength(handle); //get length of file
cout<<"file length in bytes:"<<length<<endl;
close(handle);
system("pause");
return 0;
}
£¨¶þ£©
//ÓÃWindows API ÖÐµÄ GetFileSize()»ñµÃÎļþ³¤¶È
//¼ÙÉèÎļþfile.txt ÔÚµ±Ç°Ä¿Â¼ÏÂ
//file.txtµÄÄÚÈÝΪ:123abc
//¹ØÓÚwindows APIº¯ÊýÇé²Î¿¼²¿·Öwindows APIº¯Êý»òMSDN
#include <iostream>
#include <windows.h> //for windows api
using namespace std;
int main()
{
//ÓÃAPIº¯ÊýCreateFile()´´½¨Îļþ¾ä±ú
HANDLE fhadle = CreateFile("file.txt", //ÎļþÃû»ò·¾¶
0,
0,
0,
OPEN_EXISTING, //Îļþ´æÔÚÔò´ò¿ª²¢¶ÁÈ¡
Ïà¹ØÎĵµ£º
ΪʲôÐèҪʹÓÃextern "C"ÄØ£¿C++Ö®¸¸ÔÚÉè¼ÆC++֮ʱ£¬¿¼Âǵ½µ±Ê±ÒѾ´æÔÚÁË´óÁ¿µÄC´úÂ룬ΪÁËÖ§³ÖÔÀ´µÄC´úÂëºÍÒѾдºÃC¿â£¬ÐèÒªÔÚC++Öо¡¿ÉÄܵÄÖ§³ÖC£¬¶øextern "C"¾ÍÊÇÆäÖеÄÒ»¸ö²ßÂÔ¡£
¡¡¡¡ÊÔÏëÕâÑùµÄÇé¿ö:Ò»¸ö¿âÎļþÒѾÓÃCдºÃÁ˶øÇÒÔËÐеúÜÁ¼ºÃ£¬Õâ¸öʱºòÎÒÃÇÐèҪʹÓÃÕâ¸ö¿âÎļþ£ ......
ASA¾ÖÓòÍøC/S¼Ü¹¹ÅäÖÃ×îÖÕÍêÃÀ³¬Ç¿°æ............
¾ßÌåʵÏÖÓÐÁ½ÖÖ£¬ÈçÏ£º
Ò»¡¢·þÎñÆ÷¶Ë°²×°ASA£¬ÒòΪҪʹÓÃASAÖÐ×Ô´øµÄSybase Central¹¤¾ß¡£
·þÎñÆ÷¶Ë¿ªÆô£ºscjview.exe£¨¼´£ºSybase Central£¬×¢Òâ²»ÊÇSybase Central-Sybase Central¡£½çÃæÈçͼ£º£©
1¡¢ÉèÖÃÈçÏ£ºfile£new£server
·þÎñÆ÷Ãû×ÖËæ±ãÆð£¨±ãÓÚÕâ¸ö¹¤¾ß ......
int main()
{
printf(&unix["\021%six\012\0"], (unix)["have"] + "fun" - 0x60);
}
gcc -S±àÒë³É»ã±à´úÂëÈçÏÂ:
.file "test.c"
.section .rodata
.LC0:
&nbs ......
static char *file2memory(FILE *file, long *size)
{
char buffer[1024];
char *string=NULL;
char *newstring=NULL;
long len=0;
long stringlen=0;
if(file) {
while((len = fread(buffer, 1, sizeof(buffer), f ......