C/C++¶àÖÖ·½·¨»ñÈ¡Îļþ´óС
#include <iostream>
#include <io.h>
#include <sys\stat.h>
#include <afx.h>
#define _AFXDLL
using namespace std;
void main()
{
// ´ËÎļþÔÚ¹¤³Ì´ò¿ª×´Ì¬ÏÂΪ²»¿É·ÃÎÊ
char* filepath = "..\\test.ncb";
// ·½·¨Ò»
struct _stat info;
_stat(filepath, &info);
int size = info.st_size;
cout<<size<<endl;
// ·½·¨¶þ
FILE* file = fopen(filepath, "rb");
if (file)
{
int size = filelength(fileno(file));
cout<<size<<endl;
fclose(file);
}
// ·½·¨Èý
CFile cfile;
if (cfile.Open(filepath, CFile::modeRead))
{
int size = cfile.GetLength();
cout<<size<<endl;
}
// ·½·¨ËÄ
HANDLE handle = CreateFile(filepath, FILE_READ_EA, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
if (handle != INVALID_HANDLE_VALUE)
{
int size = GetFileSize(handle, NULL);
cout<<size<<endl;
Close
Ïà¹ØÎĵµ£º
Ç°Á½ÌìÔÚÍøÉÏ¿´µ½¡¶Cר¼Ò±à³Ì¡·Õâ±¾ÊéµÄÆÀ¼Û»¹²»´í£¬¾ÍÈ¥ÊéµêÂòÁËÒ»±¾»ØÀ´Åõ¶Á£¬Ã¿ÌìÍíÉÏ¿´Ò»Ð©¡£Ì½ÌÖµÄÎÊÌâȷʵ±È½ÏÉ¶¼ÔÚÌÖÂÛCÓïÑÔ±¾ÉíµÄÎÊÌâÁË¡£Ìáµ½ÁËCÓïÑÔÖеÄһЩ²»×ã¡£±¾À´ÈÏΪCÓïÑÔÊÇÎÞи¿É»÷µÄ£¬¿É´Ó×÷ÕߵĽǶȿ´À´£¬È·ÊµÓÐЩ²»Í׵ĵط½£¬ÏëÏëÒ²ÊÇ£¬ÄÄÓÐÍêÃÀÎÞȱ¶«Î÷ÄØ¡£Æäʵ×÷ÕßÒ²²¢·ÇÔڱᵠ......
5¡¢#defineºê¶¨Òå¡£ºêÖ»ÊǼòµ¥µÄÎı¾Ìæ»»£¬ºÜÈÝÒ×ÒýÆðÆçÒå¡£
#include <stdio.h>
#define CONS(a,b) (int)(a##e##b)
#define STR(s) #s
int main()
{
printf(STR(vck));
printf("\n");
printf("%d\n",CONS(2,3));
return 0; ......
C³ÌÐòÊÇÓÉÒ»×é»òÊDZäÁ¿»òÊǺ¯ÊýµÄÍⲿ¶ÔÏó×é³ÉµÄ¡£ º¯ÊýÊÇÒ»¸ö×ÔÎÒ°üº¬µÄÍê³ÉÒ»¶¨Ïà¹Ø¹¦ÄܵÄÖ´ÐдúÂë¶Î¡£ÏÂÃæС±àºÍ´ó¼Ò·ÖÏíÏÂCÓïÑÔÖеĺ¯Êý¡£
1. ldexpº¯Êý
ldexpº¯ÊýµÄ¹¦ÄÜÊǼÆËãvalue*2µÄÃÝ£¬ÆäÓ÷¨Îª£ºdouble ldexp(double value, int exp);³ÌÐòʵÀýÈçÏ£º
......
C³ÌÐòÊÇÓÉÒ»×é»òÊDZäÁ¿»òÊǺ¯ÊýµÄÍⲿ¶ÔÏó×é³ÉµÄ¡£ º¯ÊýÊÇÒ»¸ö×ÔÎÒ°üº¬µÄÍê³ÉÒ»¶¨Ïà¹Ø¹¦ÄܵÄÖ´ÐдúÂë¶Î¡£ÏÂÃæС±àºÍ´ó¼Ò·ÖÏíÏÂCÓïÑÔÖеĺ¯Êý¡£
1. normvideoº¯Êý
mallocº¯ÊýµÄ¹¦ÄÜÊÇÑ¡ÔñÕý³£ÁÁ¶È×Ö·û£¬ÆäÓ÷¨Îª£ºvoid normvideo(void);³ÌÐòʵÀýÈçÏ£º
#include < ......
C³ÌÐòÊÇÓÉÒ»×é»òÊDZäÁ¿»òÊǺ¯ÊýµÄÍⲿ¶ÔÏó×é³ÉµÄ¡£ º¯ÊýÊÇÒ»¸ö×ÔÎÒ°üº¬µÄÍê³ÉÒ»¶¨Ïà¹Ø¹¦ÄܵÄÖ´ÐдúÂë¶Î¡£ÏÂÃæС±àºÍ´ó¼Ò·ÖÏíÏÂCÓïÑÔÖеĺ¯Êý¡£
1. qsortº¯Êý
qsortº¯ÊýµÄ¹¦ÄÜÊÇʹÓÿìËÙÅÅÐòÀý³Ì½øÐÐÅÅÐò£¬ÆäÓ÷¨Îª£ºvoid qsort(void *base, int nelem, int width, int (*fcmp)());³Ì ......