freadº¯ÊýºÍfwriteº¯Êý
1.º¯Êý¹¦ÄÜ
ÓÃÀ´¶Áдһ¸öÊý¾Ý¿é¡£
2.Ò»°ãµ÷ÓÃÐÎʽ
fread(buffer,size,count,fp);
fwrite(buffer,size,count,fp);
3.˵Ã÷
£¨1£©buffer£ºÊÇÒ»¸öÖ¸Õ룬¶ÔfreadÀ´Ëµ£¬ËüÊǶÁÈëÊý¾ÝµÄ´æ·ÅµØÖ·¡£¶ÔfwriteÀ´Ëµ£¬ÊÇÒªÊä³öÊý¾ÝµÄµØÖ·¡£
£¨2£©size£ºÒª¶ÁдµÄ×Ö½ÚÊý£»
£¨3£©count:Òª½øÐжÁд¶àÉÙ¸ösize×Ö½ÚµÄÊý¾ÝÏ
£¨4£©fp:ÎļþÐÍÖ¸Õë¡£
×¢Ò⣺1 Íê³É´Îд²Ù(fwrite())×÷ºó±ØÐë¹Ø±ÕÁ÷(fclose());
2 Íê³ÉÒ»´Î¶Á²Ù×÷(fread())ºó£¬Èç¹ûûÓйرÕÁ÷(fclose()),ÔòÖ¸Õë(FILE * fp)×Ô¶¯ÏòºóÒƶ¯Ç°Ò»´Î¶ÁдµÄ³¤¶È£¬²»¹Ø±ÕÁ÷¼ÌÐøÏÂÒ»´Î¶Á²Ù×÷Ôò½Ó×ÅÉϴεÄÊä³ö¼ÌÐøÊä³ö;
3 fprintf() £º °´¸ñʽÊäÈëµ½Á÷£¬ÆäÔÐÍÊÇint fprintf(FILE *stream, const char *format[, argument, ...]);ÆäÓ÷¨ºÍprintf()Ïàͬ£¬²»¹ý²»ÊÇдµ½¿ØÖÆ̨£¬¶øÊÇдµ½Á÷°ÕÁË¡£×¢ÒâµÄÊÇ·µ»ØֵΪ´Ë´Î²Ù×÷дÈëµ½ÎļþµÄ×Ö½ÚÊý¡£Èçint c = fprintf(fp, "%s %s %d %f", str1,str2, a, b) ;str1£º10×Ö½Ú£»str2£º 10×Ö½Ú£»a£º2×Ö½Ú£»b£º8×Ö½Ú£¬cΪ33£¬ÒòΪдÈëʱ²»Í¬µÄÊý¾Ý¼ä×Ô¶¯¼ÓÈëÒ»¸ö¿Õ¸ñ¡£
ÎļþʹÓÃÖ®ºóÒ»¶¨Òª¹Ø±Õ,·ñÔò½«²»ÄÜÕýÈ·ÏÔʾÄÚÈÝ.fwrite:¶ÁÈëÁ½¸öѧÉúÐÅϢȻºóÓÃfwrite´æÈëÎļþ
fread:ÓÃfread´ÓÎļþÖжÁ³öѧÉúÐÅÏ¢¡£
fwrite.c
#include <stdio.h>
#define SIZE 2
struct student_type
{
char name[10];
int num;
int age;
char addr[10];
}stud[SIZE];
void save()
{
FILE *fp;
int i;
if((fp=fopen("stu_list","wb"))==NULL)
{
printf("cant open the file");
exit(0);
}
for(i=0;i<SIZE;i++)
{
if(fwrite(&stud[i],sizeof(struct student_type),1,fp)!=1)
printf("file write error\n");
}
fclose(fp);
}
main()
{
int i;
for(i=0;i<SIZE;i++)
{
scanf("%s%d%d%s",&stud[i].name,&stud[i].num,&stud[i].age,&stud[i].addr);
save();
}
for(i=0;i<SIZE;i++)
{
printf("%s,%
1.·Ö²ãÉè¼Æ£¬¸ôÀëƽ̨Ïà¹ØµÄ´úÂë¡£¾ÍÏñ¿É²âÊÔÐÔÒ»Ñù£¬¿ÉÒÆÖ²ÐÔÒ²Òª´ÓÉè¼Æ×¥Æð¡£Ò»°ãÀ´Ëµ£¬×îÉϲãºÍ×îϲ㶼²»¾ßÓÐÁ¼ºÃµÄ¿ÉÒÆÖ²ÐÔ¡£×îÉϲãÊÇ
GUI£¬´ó¶àÊýGUI¶¼²»ÊÇ¿çƽ̨µÄ£¬ÈçWin32 SDKºÍMFC¡£×îϲãÊDzÙ×÷ϵͳAPI£¬´ó¶à²¿·Ö²Ù×÷ϵͳAPI¶¼ÊÇרÓõġ£
¡¡¡¡
Èç¹ûÕâÁ½²ãµÄ´úÂëÉ¢²¼ÔÚÕû¸öÈí¼ ......
BoundsChecker²ÉÓÃÒ»ÖÖ±»³ÆΪ Code InjectionµÄ¼¼Êõ£¬À´½Ø»ñ¶Ô·ÖÅäÄÚ´æºÍÊÍ·ÅÄÚ´æµÄº¯ÊýµÄµ÷Ó᣼òµ¥µØ˵£¬µ±ÄãµÄ³ÌÐò¿ªÊ¼ÔËÐÐʱ£¬BoundsCheckerµÄDLL±»×Ô¶¯ÔØÈë½ø³ÌµÄµØÖ·¿Õ¼ä£¨Õâ¿ÉÒÔͨ¹ýsystem-levelµÄHookʵÏÖ£©£¬È»ºóËü»áÐ޸Ľø³ÌÖжÔÄÚ´æ·ÖÅäºÍÊͷŵĺ¯Êýµ÷Óã¬ÈÃÕâЩµ÷ÓÃÊ×ÏÈתÈëËüµÄ´úÂ룬ȻºóÔÙÖ´ÐÐÔÀ´µÄ´úÂë¡£Bo ......