易截截图软件、单文件、免安装、纯绿色、仅160KB
热门标签: c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 最新文章 : c

深入理解C/C++函数指针

转:http://school.ogdev.net/ArticleShow.asp?categoryid=10&id=6019
函数指针数组的妙用
笔者在开发某软件过程中遇到这样一个问题,前级模块传给我二进制数据,输入参数为 char* buffer和 int length,buffer是数据的首地址,length表示这批数据的长度。数据的特点是:长度不定,类型不定,由第一个字节(buffer[0])标识该数据的类型,共有256(28 )种可能性。我的任务是必须对每一种可能出现的数据类型都要作处理,并且我的模块包含若干个函数,在每个函数里面都要作类似的处理。若按通常做法,会写出如下代码:
void MyFuntion( char* buffer, int length )
{
    __int8 nStreamType = buffer[0];
    switch( nStreamType )
    {
       case 0:
           function1();
           break;
       case 1:
       ......
       case 255:
           function255();
           break;
     }
}
如果按照这种方法写下去,那么在我的每一个函数里面,都必须作如此多的判断,写出的代码肯定很长,并且每一次处理,都要作许多次判断之后才找到正确 ......

深入理解C/C++函数指针

转:http://school.ogdev.net/ArticleShow.asp?categoryid=10&id=6019
函数指针数组的妙用
笔者在开发某软件过程中遇到这样一个问题,前级模块传给我二进制数据,输入参数为 char* buffer和 int length,buffer是数据的首地址,length表示这批数据的长度。数据的特点是:长度不定,类型不定,由第一个字节(buffer[0])标识该数据的类型,共有256(28 )种可能性。我的任务是必须对每一种可能出现的数据类型都要作处理,并且我的模块包含若干个函数,在每个函数里面都要作类似的处理。若按通常做法,会写出如下代码:
void MyFuntion( char* buffer, int length )
{
    __int8 nStreamType = buffer[0];
    switch( nStreamType )
    {
       case 0:
           function1();
           break;
       case 1:
       ......
       case 255:
           function255();
           break;
     }
}
如果按照这种方法写下去,那么在我的每一个函数里面,都必须作如此多的判断,写出的代码肯定很长,并且每一次处理,都要作许多次判断之后才找到正确 ......

Linux C notes (BOOK UNIX)

Chapter 1: Thread
① thread functions
1. pthread_self();
2. thread existing
    you can get the value of rval_ptr just by  pthread_join(pthread_t tht, void ** rval_ptr)
    cancel a thread as the thread exits with PTHREAD_CANCELED in pthread_exit, this function        only send a signal but not wait until the thread really exits
        We can give a function to a thread with which the thread can invoke it when it exits. This
        pthread_clean_push
        These two functions must be in pairs in your function routines but not in the main                function. And one thing should be mentioned as : the routine should not be returned but
        pthread_detach(pthread_t tid)
4. Thread synchronization of thread
② thread. synchronics ......

Linux C notes (BOOK UNIX)

Chapter 1: Thread
① thread functions
1. pthread_self();
2. thread existing
    you can get the value of rval_ptr just by  pthread_join(pthread_t tht, void ** rval_ptr)
    cancel a thread as the thread exits with PTHREAD_CANCELED in pthread_exit, this function        only send a signal but not wait until the thread really exits
        We can give a function to a thread with which the thread can invoke it when it exits. This
        pthread_clean_push
        These two functions must be in pairs in your function routines but not in the main                function. And one thing should be mentioned as : the routine should not be returned but
        pthread_detach(pthread_t tid)
4. Thread synchronization of thread
② thread. synchronics ......

c/c++中内存区域划分大总结

一. 在c中分为这几个存储区
1.栈 - 由编译器自动分配释放
2.堆 - 一般由程序员分配释放,若程序员不释放,程序结束时可能由OS回收
3.全局区(静态区),全局变量和静态变量的存储是放在一块的,初始化的全局变量和静态变量在一块区域,未初始化的全局变量和未初始化的静态变量在相邻的另一块区域。- 程序结束释放
4.另外还有一个专门放常量的地方。- 程序结束释放
                                                                                                             &nb ......

c/c++中内存区域划分大总结

一. 在c中分为这几个存储区
1.栈 - 由编译器自动分配释放
2.堆 - 一般由程序员分配释放,若程序员不释放,程序结束时可能由OS回收
3.全局区(静态区),全局变量和静态变量的存储是放在一块的,初始化的全局变量和静态变量在一块区域,未初始化的全局变量和未初始化的静态变量在相邻的另一块区域。- 程序结束释放
4.另外还有一个专门放常量的地方。- 程序结束释放
                                                                                                             &nb ......

自动更改桌面背景 c/c++ win32

这个程序仅供编程参考
若想在平时用,请下载微软的wallpaper changer
我这个程序实现了定时更换桌面背景的功能
命令行 wallpaper "your images' directory path" time_in_minute
编程要点
findfirstfile findnextfile 查找图像文件
SystemParametersInfo  修改系统信息,在这儿当然是桌面背景
注册表操作 保存信息
如果做得实用,应加入开机启动功能,自然还要gui
//wallpaper.c
//by onezeros@yahoo.cn||Zhijie Lee
//usage:wallpaper "full directory path" interval
// interval is in minutes
#include <windows.h>
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
/* argc=3;
argv[1]="E:\\picture\\testbmp";
argv[2]="1";
*/ LPCSTR currentDir;
LPCSTR currentImage;
int interval;

HKEY hKey;
WIN32_FIND_DATAA FileData;
HANDLE hFind;

//initialize parameters
if(argc==1){
//find parameters in registry
if(RegOpenKeyA(HKEY_LOCAL_MACHINE,(LPCSTR)"Software\\wallpaper",
&hKey)!=ERROR_SUCCESS||
RegQueryValue ......

自动更改桌面背景 c/c++ win32

这个程序仅供编程参考
若想在平时用,请下载微软的wallpaper changer
我这个程序实现了定时更换桌面背景的功能
命令行 wallpaper "your images' directory path" time_in_minute
编程要点
findfirstfile findnextfile 查找图像文件
SystemParametersInfo  修改系统信息,在这儿当然是桌面背景
注册表操作 保存信息
如果做得实用,应加入开机启动功能,自然还要gui
//wallpaper.c
//by onezeros@yahoo.cn||Zhijie Lee
//usage:wallpaper "full directory path" interval
// interval is in minutes
#include <windows.h>
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
/* argc=3;
argv[1]="E:\\picture\\testbmp";
argv[2]="1";
*/ LPCSTR currentDir;
LPCSTR currentImage;
int interval;

HKEY hKey;
WIN32_FIND_DATAA FileData;
HANDLE hFind;

//initialize parameters
if(argc==1){
//find parameters in registry
if(RegOpenKeyA(HKEY_LOCAL_MACHINE,(LPCSTR)"Software\\wallpaper",
&hKey)!=ERROR_SUCCESS||
RegQueryValue ......

Six BS HelloWorld from C World

#define _________ } 
#define ________ putchar
#define _______ main 
#define _(a) ________(a); 
#define ______ _______(){ 
#define __ ______ _(0x48)_(0x65)_(0x6C)_(0x6C) 
#define ___ _(0x6F)_(0x2C)_(0x20)_(0x77)_(0x6F) 
#define ____ _(0x72)_(0x6C)_(0x64)_(0x21) 
#define _____ __ ___ ____ _________ 
#include<stdio.h> 
#include<stdio.h> 
main(){ 
  int x=0,y[14],*z=&y;*(z++)=0x48;*(z++)=y[x++]+0x1D; 
  *(z++)=y[x++]+0x07;*(z++)=y[x++]+0x00;*(z++)=y[x++]+0x03; 
  *(z++)=y[x++]-0x43;*(z++)=y[x++]-0x0C;*(z++)=y[x++]+0x57; 
  *(z++)=y[x++]-0x08;*(z++)=y[x++]+0x03;*(z++)=y[x++]-0x06; 
  *(z++)=y[x++]-0x08;*(z++)=y[x++]-0x43;*(z++)=y[x]-0x21; 
  x=*(--z);while(y[x]!=NULL)putchar(y[x++]); 
}
(VS2003编译通过)
#include<stdio.h> 
#define __(a) goto a; 
#define ___(a) putchar(a); 
#define _(a,b) ___(a) _ ......

C++中extern “C”含义深层探索 [转]



1.
引言
  C++
语言的创建初衷是“a better C”
,但是这并不意味着C++
中类似C
语言的全局变量和函数所采用的编译和连接方式与C
语言完全相同。作 为一种欲与C
兼容的语言,C++
保留了一部分过程式语言的特点(被世人称为“
不彻底地面向对象”
),因而它可以定义不属于任何类的全局变量和函数。但 是,C++
毕竟是一种面向对象的程序设计语言,为了支持函数的重载,C++
对全局函数的处理方式与C
有明显的不同。
2.
从标准头文件说起
  某企业曾经给出如下的一道面试题:
  面试题
  为什么标准头文件都有类似以下的结构? 
#ifndef __INCvxWorksh
#define __INCvxWorksh 
#ifdef __cplusplus
extern "C" {
#endif 
/*...*/ 
#ifdef __cplusplus
}
#endif 
#endif /* __INCvxWorksh */
  分析
  显然,头文件中的编译宏“#ifndef __INCvxWorksh
、#define __INCvxWorksh
、#endif” 
的作用是防止该头文件被重复引用。
  那么
#ifdef __cplusplus
extern &quo ......

C++中extern “C”含义深层探索 [转]



1.
引言
  C++
语言的创建初衷是“a better C”
,但是这并不意味着C++
中类似C
语言的全局变量和函数所采用的编译和连接方式与C
语言完全相同。作 为一种欲与C
兼容的语言,C++
保留了一部分过程式语言的特点(被世人称为“
不彻底地面向对象”
),因而它可以定义不属于任何类的全局变量和函数。但 是,C++
毕竟是一种面向对象的程序设计语言,为了支持函数的重载,C++
对全局函数的处理方式与C
有明显的不同。
2.
从标准头文件说起
  某企业曾经给出如下的一道面试题:
  面试题
  为什么标准头文件都有类似以下的结构? 
#ifndef __INCvxWorksh
#define __INCvxWorksh 
#ifdef __cplusplus
extern "C" {
#endif 
/*...*/ 
#ifdef __cplusplus
}
#endif 
#endif /* __INCvxWorksh */
  分析
  显然,头文件中的编译宏“#ifndef __INCvxWorksh
、#define __INCvxWorksh
、#endif” 
的作用是防止该头文件被重复引用。
  那么
#ifdef __cplusplus
extern &quo ......
总记录数:2015; 总页数:336; 每页6 条; 首页 上一页 [186] [187] [188] [189] 190 [191] [192] [193] [194] [195]  下一页 尾页
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号