C和C++编程和学习文档
C和C++编程和学习文档
1 :指针变量名称以p为首字符,这是程序员通常在定义指针时的一个习惯
2 :har * p; (int *)p 把p强制转换为int型
3.1 :指针的问题:指针应用时最好给予定义(初始化)这样可以保证指针的指向是程序员自己能够把握的。
3.2 :指针的越界,这恐怕是最难查出的吧!
3.3 :指针的局部变量问题。局部的指针变量会被程序自动释放,若程序员引用此类指针就会出错。2007-9-1
4.二维指针的应用实例:
#include <stdio.h>
#include <string.h>
void sort(char (*client)[10]);
void main()
{
int temp;
char client[3][10];
char (*pClient)[10] = NULL;
for( temp = 0; temp < 3; temp++ )
{
gets(client[temp]);
}
pClient = client;
sort(pClient);
for( temp = 0; temp < 3; temp++ )
{
puts(*(pClient + temp));
}
}
void sort(char (*client)[10])
{
//冒泡算法的明了写法
int temp1, temp2;
&n
相关文档:
1、为了调用宏时能得到正确结果,在宏体中建议对宏的每个参数用括号括起来,并且当宏体是一个表达式时整个宏体也用括号括起来。
/* c1.c:将两个数相乘 */
#define product(x,y) ((x)*(y))
#include <stdio.h>
int main(){
int a=1,b=2,c=3,d=4,x=0;
x=product(a+3,b)+product(c,d); / ......
assert
函数名: assert
功 能: 测试一个条件并可能使程序终止
用 法: void assert(int test);
程序例:
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
struct ITEM {
int&n ......
#include "draw.h"
#include "ui_draw.h"
#include <QPixmap>
draw::draw(QWidget *parent)
: QDialog(parent), ui(new Ui::draw)
{
ui->setupUi(this);
// this->setWindowFlags( Qt::FramelessWindowHint);
ctrlPoint.s ......
本文包括大部分C标准库函数,但没有列出一些用途有限的函数以及某些可以简单的从其他函数合成的函数,也没有包含多字节和本地化函数。
标准库中的各个函数、类型以及宏分别在以下标准头文件中说明:
<assert.h> <float.h> <math.h> <stdarg.h> <stdlib.h>
<ctype.h> <limits.h& ......
在项目属性页 --> 配置属性 --> C/C++ --> 输出文件里面,将汇编输出的下拉列表从无列表选择为你需要汇编输出的内容,比如“仅列出程序集(/FA)”,如图1-1,图1-2:
图1-1
图1-2
------------------------------------------------------------------------------------------------ ......