摘要: 谭浩强绿皮书例10.28以下代码在int *num[5]={&a[0],&a[1],&a[2],&a[3],&a[4]};肯定报初始化错误。而用VS2008编译通过。原因不明。int _tmain(int argc, _TCHAR* argv[]){int a[5]={1,3,5,7,9};int *num[5]={&a[0],&a[1],&a[2],&a[3],&a[4]};int **p,i;p=num;for (i=0;i<5;i++){printf("%d",**p);p++;}p 阅读全文
posted @ 2013-02-24 14:03 yurius 阅读(161) 评论(0) 推荐(0) 编辑
摘要: fflush(stdout);可以及清空读入的缓存,谁用谁知道。fflush(FILE*)由于fread和fwrite共用一个缓存,故若不即时fflush则会有很大的问题。fflush可以立即输出。 阅读全文
posted @ 2013-02-24 13:52 yurius 阅读(218) 评论(0) 推荐(0) 编辑
摘要: 链表的插入、删除、添加,按自己想法写的代码。。。逻辑不是很明晰。。。#include<stdio.h>struct student{int score;int n;struct student *next;};struct student *creatlist(){struct student *head,*p1,*p2;head=NULL;p1=p2=(struct student *)malloc(sizeof(struct student));scanf("%d,%d",&p1->n,&p1->score);head=p1;wh 阅读全文
posted @ 2013-02-24 13:34 yurius 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 以前一直奇怪. * ./有什么用,今天测试了下。直接输入代码#include<stdio.h>void main(){float aa=10;float bb=10;aa=10. *8;bb=10. /8;printf("%f,%f",aa,bb);}输出80。000000,1.250000。可见,该运算可保留小数后面6位。、另外,即使不留空格也完全没有问题。另测了一下经常在句末风到的右斜杆\如:#define CHECK( name, limit, val ) \if( (val) > (limit) ) \ERROR( name " (%d) 阅读全文
posted @ 2013-02-24 13:32 yurius 阅读(231) 评论(0) 推荐(0) 编辑
摘要: strdup复制字符串比起strcpy,strdup可以复制给没有分配内存的指针,最后这个分给这个指针的空间释放掉(但很怪我在VC6上实验即使分配了内存,strdup依然可以进行复制,也许跟平台有关);strchr找到指定的字符,返回指向该字符的指针;strncmp比较前N个字符,相等输出0以下是vc6上的实验:#include <stdio.h>#include <string.h>void main(){char temp[32];char *s = temp;char *p,c='v';memset(temp,0,sizeof(temp));str 阅读全文
posted @ 2013-02-24 13:31 yurius 阅读(594) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>#include<stdlib.h>#include<string.h>int main(){FILE *fp=NULL;int f_size=0;char*all=NULL;fp=fopen("0.txt","r+b");if(fp==NULL){printf("open error");system("pause");}fseek(fp,0L,SEEK_END);f_size=ftell(fp);fseek(fp,0L,SEEK_SET);a 阅读全文
posted @ 2013-02-24 13:30 yurius 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 比如下面这样char* my="youwin";char youwin[50];_snprintf(youwin,strlen(my)+strlen("结果为:")+1,"结果为:%s",my);printf("%s",youwin);return 0;注意strlen是不计算末尾的那个\0的,所以要加1. 阅读全文
posted @ 2013-02-24 13:29 yurius 阅读(105) 评论(0) 推荐(0) 编辑
摘要: 1单步进入一些函数,随便如strcmp,就会弹出浏览路径,估计是只是编好的lib没有源码?还有void kq_free_list(struct kq_person* head){struct kq_person* p=NULL,*q=NULL;p=head->next;free(head);while(p!=NULL){q=p;p=p->next;free(q);}}这样没问题,可是直接free(p)就不行,奇怪。2直接看代码#include <stdio.h>#include <io.h>#include <fcntl.h>#include & 阅读全文
posted @ 2013-02-24 13:28 yurius 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 比较重要的记着strcspn这个函数只要找到一个字节相同就会返会size了,所以"、"和"隆"第一个ASC2都是-95,strcspn认为一样,直接返回。想要查找到相同的字符串再返回必须用strstr,找到地址后去减原来的地址(小心,找不到一减就负值了)。还要,这次使用冒泡排序链表,网上说其实不好什么的,不知为毛,以下是我的code,程序有点臃肿,没功夫优化了,这事纠缠了这么多天可以结束了。void kq_order(struct kq_person* head,int kq_totall){struct kq_person *p=NULL,*q=NUL 阅读全文
posted @ 2013-02-24 13:27 yurius 阅读(251) 评论(0) 推荐(0) 编辑
摘要: 不复习很快就忘了。注意最好要加括号啊!#include<stdlib.h>#include <stdio.h>#include<string.h>//#define x264_COPY2(x,y,a,b) if((x)<(y)) {x=y;a=b;}#define x264_COPY2(x,y,a,b) if((x)<(y)) {x=y;a=b;}//最好是#define x264_COPY2(x,y,a,b) if((x)<(y)) {(x)=(y);(a)=(b);}int main(){int a=0;int b=88;int aa= 阅读全文
posted @ 2013-02-24 13:26 yurius 阅读(224) 评论(0) 推荐(0) 编辑
摘要: char* aa=(char*)malloc(2);*aa++=33;结果是,先给*a赋33,然后再++。下面是汇编代码:56: *aa++=33;00401035 mov eax,dword ptr [ebp-4]00401038 mov byte ptr [eax],21h0040103B mov ecx,dword ptr [ebp-4]0040103E add ecx,100401041 mov dword ptr [ebp-4],ecx[ebp-4]是给局部量分配空间。21h无疑是33啦。另有坑爹问题一个:函数声明是void (*intra_satd_x3_8x8c) ( uint8 阅读全文
posted @ 2013-02-24 13:25 yurius 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 直接看代码,仿计算satd的函数typedef int (*x264_pixel_cmp_t) ( uint8_t *, int, uint8_t *, int );typedef int (*x264_test)(int,int);int addab(int a,int b);int c=0;x264_test x_t[20];x_t[10]=addab;c=x_t[10](1000,200);//注意这里的x_t[10]已经是相当于*(x_t+10),故不用再加*printf("%d",c);return 0;}int addab(int a,int b){return 阅读全文
posted @ 2013-02-24 13:22 yurius 阅读(118) 评论(0) 推荐(0) 编辑
摘要: 一、int aa[2][3][2]={{{1,2},{3,4},{5,6}},{{7,8},{9,10},{1,2}}};__int64 b=*(__int64*)aa[1][2];__int64 a;a=b>>32;//高位printf("%d\n",a);int c;c=(int)b;//低位printf("%d\n",c);输出:21二、int a=0x0101;short b;b=a;这样赋值连个warning都没有,是无一点问题的。同样地:int a=0x41;unsigned char b;b=a;这样也是OK的。三、设dst是一 阅读全文
posted @ 2013-02-24 13:18 yurius 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 1VC的>>按位右移反汇编是sar算术右移,即保持最高位不变往右移。2 这个:static inline uint8_t x264_clip_uint8( int x ){return x&(~255) ? (-x)>>31 : x;}x&(~255)即x与FFFFFF00按位与,这样如果x只有低8位(一个字节),就保持不变(合函数名)如果x高于8位,且是正数则(-x)>>31是将其符号取反后取出。注意,用最高位表示符号则正负各能占一半。 阅读全文
posted @ 2013-02-24 13:17 yurius 阅读(917) 评论(0) 推荐(0) 编辑
摘要: 1.cpp#include <stdio.h>#include<stdlib.h>#define one123 123extern bb;void main(){int aa;aa=1;aa=one123;printf("%d\n",aa);printf("%d",bb);}2.cpp#define one123 233int bb=one123;总结:两个文件的宏定义只在本文件中有效,不干涉其它文件,而若要用到另一文件的变量必须extern 阅读全文
posted @ 2013-02-24 13:15 yurius 阅读(967) 评论(0) 推荐(0) 编辑
摘要: 1 我一直以为运行后才会生成.exe,才知道编译成功就生成了,坑爹啊。。。。2把文件拖拽到cmd里,cmd会自动把文件的完整路径写在命令行上3 头文件和源文件不必一一对应,如函数在1.h里声明,在2.c里实现,在3里包含1.h仍可以通过4程序如下:char aa=0;int bb=1;int cc=0x0f0f0f0f;int dd=0x01040508;则他们的地址如下:+ &aa 0x0012ff7c ""+ &bb 0x0012ff78+ &cc 0x0012ff74+ &dd 0x0012ff70正好相反。5void* 也可以代替FI 阅读全文
posted @ 2013-02-24 13:14 yurius 阅读(348) 评论(0) 推荐(0) 编辑
摘要: 1 先做好一个lib,编译后会在debug中生成一个lib2 将lib拷贝到要使用该lib的工程文件夹里3 在工程设置的object/lib modules 里添加些lib4 在要调用此lib的工程声明定义在lib的函数,即可直接使用 阅读全文
posted @ 2013-02-24 13:13 yurius 阅读(436) 评论(0) 推荐(0) 编辑
摘要: 直接看代码1.cppint add(int a);void myini();int abcaaa();extern int abc;//int abc;int main(){myini();int a=1;int z=add(a);printf("the z is %d\n",z);printf("the abc is %d",abc);int zz=abcaaa();printf("z is %d\n",zz);return 0;}2.cppint abc=212;int aaa=0;int add(int a){return (a 阅读全文
posted @ 2013-02-24 13:12 yurius 阅读(260) 评论(0) 推荐(0) 编辑
摘要: typedef void (*IntegralFunc)(const uchar* src, size_t srcstep, uchar* sum, size_t sumstep,uchar* sqsum, size_t sqsumstep, uchar* tilted, size_t tstep,Size size, int cn );一旦如此,就可以使用IntegralFunc去定义了。如IntegralFunc func;直接看一段代码typedef int (* func)(int ,int ) ;int add(int a,int b){return (a+b);}void main 阅读全文
posted @ 2013-02-24 13:10 yurius 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 一、预备知识―程序的内存分配 一个由c/C++编译的程序占用的内存分为以下几个部分 1、栈区(stack)― 由编译器自动分配释放 ,存放函数的参数值,局部变量的值等。其操作方式类似于数据结构中的栈。 2、堆区(heap) ― 一般由程序员分配释放, 若程序员不释放,程序结束时可能由OS回收 。注意它与数据结构中的堆是两回事,分配方式倒是类似于链表,呵呵。 3、全局区(静态区)(static)―,全局变量和静态变量的存储是放在一块的,初始化的全局变量和静态变量在一块区域, 未初始化的全局变量和未初始化的静态变量在相邻的另一块区域。 - 程序结束后有系统释放 4、文字常量区 ―常量字符... 阅读全文
posted @ 2013-02-24 13:09 yurius 阅读(344) 评论(0) 推荐(0) 编辑