- 博客(16)
- 资源 (8)
- 收藏
- 关注
原创 函数指针的使用
#include <stdio.h>typedef int(FUNCTION)(int);int f(int i){ return i;}int main(void){ FUNCTION* func = f; printf("%d\n",func(13)); printf("---end---\n"); return 0;}
2016-06-26 11:30:22 343
原创 二维数组的调用方式
#include <stdio.h>void print_2DArray(int a[][4],int row) //int a[][4] -> int (*a)[4]{ int col = sizeof(*a)/sizeof(int); printf("col = %d\n",col); int i = 0; int j = 0; printf("siz
2016-06-26 11:20:12 4214
原创 动态申请二维数组的方式和遍历二维数组的两种方式
#include <stdio.h>#include <malloc.h>int** malloc2D(int row,int col){ int** ret = (int**)malloc(col*sizeof(int*)); int* p = (int*)malloc(col*row*sizeof(int)); int i = 0; if((ret!=NULL
2016-06-26 10:13:31 1095
原创 使用一维数组或指针遍历二维数组
//使用一维数组打印二维数组#include <stdio.h>void print_array(int* a,int length){ int i = 0; for(i=0;i<length;i++) { printf("%d: %d\n",i,a[i]); }}int main(void){ int a[3][3] = {{1,2,3
2016-06-26 09:34:36 1887
原创 动态一维数组的使用
#include <stdio.h>#include <stdlib.h>#include <malloc.h>int myReset(char** p,int size,int new_size){ int ret = 1; int i = 0; int len = 0; char* pc = NULL; if((*p!=NULL)&&(new_si
2016-06-25 09:34:43 936
原创 一维数组和二维数组的传值问题
一个简单的关系:#include <stdio.h>int main(void){ int a = 1; int* p = &a; int** pp = &p; printf("a = %d\n",a); printf("*p = %d\n",*p); printf("**pp = %d\n",**pp); **pp = 8; printf
2016-06-24 11:29:02 514
原创 指针数组--main参数
#include <stdio.h>#include <string.h>#define DIM(a) (sizeof(a)/sizeof(*a))int lookupKeyword(const char* key,const char* table[],const int size){ int ret = -1; int i = 0; for(i=0;i<size;i+
2016-06-24 10:35:57 204
原创 数组指针的使用
/*数组指针的使用*/#include <stdio.h>typedef int(AINT5)[5]; //数组类型为:int[5]typedef char(ACHAR2)[2];void test_1(){ AINT5 a; //等同于 int a[5] AINT5* a1 = &a; //等同于 int (*a1)[5] int i=0; printf(
2016-06-24 09:50:28 261
原创 strcpy的使用--安全编程策略
#include <stdio.h>#include <assert.h>#include <malloc.h>char* myStrcpy(char* dst,const char* src){ char* ret = dst; assert(dst&&src);//安全编程策略,一定要写这一句代码,确保dst和src都不为空 while((*dst++ = *src
2016-06-23 10:38:23 468
原创 strlen的使用
#include <stdio.h>size_t myStrlen(const char* s){ size_t length = 0; while(*s++) //遇到\0就返回 { length++; } return length;}int main(void){ char* s1 = "hello"; char*
2016-06-23 10:10:04 1532
原创 #pragma pack(n)的use(看编辑)
#include <stdio.h>#include <stdlib.h>#pragma pack(8)struct S1{ short a; long b;};struct S2{ char c; struct S1 d; double e;};int main(void){ struct S2 s20; printf("siz
2016-06-21 11:12:30 427
原创 QString与QByteArray互相转换的方法
// QString转QByteArray方法//Qt5.3.2QString str("hello"); QByteArray bytes = str.toUtf8(); // QString转QByteArray方法1 QString str("hello"); QByteArray bytes = str.toLatin1(); // QString转QByteArray方法2//
2016-06-14 21:22:56 56414
原创 柔性数组的使用
#include <stdio.h>#include <malloc.h>typedef struct _soft_array{ int len; int a[];}SoftArray;int main(void){ int i = 0; printf("sizeof(SoftArray) = %d\n",sizeof(SoftArray)); //si
2016-06-12 15:14:20 495
原创 关于传递参数时,涉及数组的length = sizeof(a)/sizeof(int)还是为length = sizeof(a)的总结
1.以memset函数举例说明吧!#include <mem.h>void test_memset(){ printf("set int to 0\n"); int a[] = {1,2,3,4,5}; //int length = sizeof(a)/sizeof(int);//不能使用sizeof(c)/sizeof(int) int length = siz
2016-06-12 10:23:11 3532 1
原创 查看Qt中可用的数据库插件
(QT 版本为5.3.2) 1.新建空的Qt项目,项目名为:databaseDriver 2.往项目中添加新的main.cpp文件 3.在databaseDriver.pro文件中添加如下一行代码: QT += sql QT += widgets#include <QApplication>#include <QSqlDatabase>#include <QDebug>#inclu
2016-06-08 09:22:04 2152 1
转载 QT5.3.2中新建 “空的Qt项目”出现不支持QApplication的解决方案
出现原因:Qt5里QApplication不再用QtGui模块,而是使用QtWidgets模块。Qt5中所有的组件都是在widgets模块中定义的解决方法:在.pro里加上QT += widgets然后重新编译运行
2016-06-08 09:15:19 1056
the java programming language fourth editionArnoldGoslingHolmes06
2014-08-30
ascii-码表
2014-08-30
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人