函式指標等的一些用法總結

2021-08-29 20:16:09 字數 2111 閱讀 6154

int _tmain(int argc, _tchar* argv)

*///template

#include "stdafx.h"

/*#include

#include

#include

using namespace std;

//c++寫檔案和讀檔案

int main()

ifstream in("d:\\out1.txt");

if (!in.is_open())

while(!in.eof())

*///函式指標

//int (*pfun)(int i ,int j);

/*#include

#include

#include

using namespace std;

int main()

//cout << vec.size() << " " << vec.capacity() << endl;

//cout<<"after push  " << vec.size()<<" " //函式指標

int(*pfun)(void);

typedef int(*pfun)(int, int);

#include

#include

using namespace std;

typedef int(*addfunc)(int a, int b);

int main(int argc, char *argv)

freelibrary(hdll);}}

*/#include

#include

#include

using namespace std;

struct node

};int insert(node *pnode, int val)

}node *pnew = new node();

p1->pnext = pnew;

pnew->pnext = p2;

return 0;

}struct mystruct

;void test(char **p)

typedef int(*pfun)(int, int);

int add(int a, int b)

int main(){/*

int i = 4;

i <<= 3;

cout << "----i " <

/*//sizeof和strlen求字串長度,strlen求得的大小不包含'\0',sizeof包含'\0'

char *p = "hello world";

int n = sizeof(p);

int nlength = strlen(p);

cout << "sizeof p:" << n << endl;

cout << "strlen:" << nlengthint nn = sizeof(strarray);

int nlen = strlen(strarray);

cout << "sizeof array:" << nn << endl;

cout << "strlen array:" << nlen << endl;

*//*

//sizeof對指標和結構體求位元組數

mystruct *pmystruct = (mystruct *)malloc(sizeof(mystruct));

int n = sizeof(pmystruct);

int nn = sizeof(*pmystruct);

int nnn = sizeof(mystruct);

memset(pmystruct, 0, nn);

//memset_s(pmystruct, nn,0,nn);

cout << "sizeof *pmystruct: " //二級指標用法

char *pp = new char[20];

test(&pp);

/*//函式指標的用法

pfun pfun = add;

int a = pfun(1, 2);

int aa = (*pfun)(1, 2);

cout<<"

函式指標陣列的一些用法

首先函式指標陣列是陣列,其次陣列裡面存放的是函式指標,函式指標又是什麼呢,函式指標是指向函式首位址的指標,我個人認為函式指標陣列可以批量像呼叫陣列元素一樣方便呼叫一些功能相似的一些函式 小弟愚見 我寫這個部落格之前就是遇到這個問題。首先介紹一下我遇到問題背景,想做個mini3216時鐘,顯示時間是用...

Python一些函式的用法總結

一 字串的split用法 描述 python split 通過指定分隔符對字串進行切片,如果引數 num 有指定值,則僅分隔 num 個子字串 語法 split 方法語法 str.split str num string.count str 引數 str 分隔符,預設為所有的空字元,包括空格 換行 ...

指標的一些總結

2016年9月14日 指標陣列和陣列指標 指標陣列是指 陣列元素都是指標 int ptr 5 int a 2,b 3,c 6,p,q p a q b ptr 0 a 存入的是a的位址 ptr 1 b ptr 2 c cout ptr 0 ptr 0 endl cout ptr 1 ptr 1 end...