把书本上没有见过的一些类型记录在此,可以回顾。!!~~
在优快云的论坛上提供了一段代码:
其中出现了一个在此之前没有看过的数据类型。记录一下。


1 #include <sys\stat.h> 2 #include <io.h> 3 #include <fcntl.h> 4 #include <share.h> 5 #include <stdlib.h> 6 #include <stdio.h> 7 #include <conio.h> 8 #include <string.h> 9 #define MAX_CLU_BYTES 65536 10 FILE *fo; 11 int fh; 12 __int64 offs,offs1; 13 __int64 rvi64; 14 int rv,wrv; 15 unsigned char buf[MAX_CLU_BYTES]; 16 char ofn[_MAX_PATH]; 17 char offstr[80]; 18 void strcpybutcomma(char *t,char *s) { 19 char c; 20 21 while (1) { 22 c = *s++; 23 if (','!=c) *t++ = c; 24 if (0==c) break; 25 } 26 } 27 void main(int argc,char **argv) { 28 if (argc<3) { 29 printf("Copy File Tail.\n"); 30 printf("Usage:\n"); 31 printf(" cft filename.ext offset_begin[-offset_end]\n"); 32 printf("Copy filename.ext offset_begin[-offset_end] to offset_begin[-offset_end]-filename.ext\n"); 33 printf("Note: Byte at offset_end is NOT included.\n"); 34 printf("Example:\n"); 35 printf(" cft abc.rar 12345\n"); 36 printf("Copy abc.rar offset 12345-end to 12345-abc.rar\n"); 37 printf(" cft abc.rar 123-12345\n"); 38 printf("Copy abc.rar offset 123-12345 to 123-12345-abc.rar\n"); 39 printf(" cft abc.rar 0xAB-0xCD\n"); 40 printf("Copy abc.rar offset 0xAB-0xCD to 0xAB-0xCD-abc.rar\n"); 41 return; 42 } 43 strcpybutcomma(offstr,argv[2]); 44 rv=sscanf(offstr,"%I64i-%I64i",&offs,&offs1); 45 if (rv==0) { 46 printf("offset %s is not number\n",argv[2]); 47 return; 48 } 49 fh=_sopen(argv[1],_O_BINARY|_O_RDONLY|_O_RANDOM,_SH_DENYWR); 50 if (fh==-1) { 51 printf("_sopen %s errno=%d\n",argv[1],errno); 52 return; 53 } 54 if (rv==1) { 55 offs1=_filelengthi64(fh); 56 if (offs1==-164i) { 57 printf("%I64=_filelengthi64 errno=%d\n",offs1,errno); 58 _close(fh); 59 return; 60 } 61 } else {//rv==2 62 if (offs1<offs) { 63 printf("%s offset_begin>offset_end error\n",argv[2]); 64 _close(fh); 65 return; 66 } 67 } 68 rvi64=_lseeki64(fh,offs,SEEK_SET); 69 if (rvi64!=offs) { 70 printf("%I64u=_lseeki64 %I64u errno=%d\n",rvi64,offs,errno); 71 _close(fh); 72 return; 73 } 74 sprintf(ofn,"%s-",offstr); 75 strcat(ofn,argv[1]); 76 fo=fopen(ofn,"wb"); 77 if (fo==NULL) { 78 _close(fh); 79 printf("fopen %s error\n",ofn); 80 return; 81 } 82 cprintf("\n%I64u\r",offs); 83 while (1) { 84 rv=_read(fh,buf,(unsigned int)__min(offs1-offs,MAX_CLU_BYTES)); 85 if (rv==0) break;// 86 if (rv<0) { 87 fclose(fo); 88 _close(fh); 89 printf("_read %s offset %I64u error\n",argv[1],offs); 90 return; 91 } 92 wrv=fwrite(buf,1,rv,fo); 93 if (wrv!=rv) { 94 fclose(fo); 95 _close(fh); 96 printf("fwrite %s error\n",ofn); 97 return; 98 } else { 99 offs+=rv; 100 cprintf("%I64u\r",offs); 101 if (offs>=offs1) break;// 102 } 103 } 104 fclose(fo); 105 _close(fh); 106 printf("Copy %s offset %s to %s OK.\n",argv[1],argv[2],ofn); 107 }
在程序中出现__int64这个数据类型。现在说说自己找到并学习到的内容。
现在还不知道它在哪个库上的。
根据参考内容,得知:
typedef __int64 LONGLONG;
“typedef为C语言的关键字,作用是为一种数据类型定义一个新名字。
在编程中使用typedef目的一般有两个,一个是给变量一个易记且意义明确的新名字,另一个是简化一些比较复杂的类型声明。
“在格式化输出则还需要结合一个d,即%I64d。对于无符号的ULONGLONG,则是%I64u。
内容参考网址:
C++零食:wprintf 中使用%I64d格式化输出LONGLONG:"http://www.cnblogs.com/greenerycn/archive/2010/09/01/format_longlong.html"
typedef_百度百科:"http://baike.baidu.com/view/1283800.htm"
C/C++的64位整型:"http://www.byvoid.com/blog/c-int64/"
其中《C/C++的64位整型》上的内容强大。。找到自己所要的信息。
待续。