c++ tips

2008-1-15

1 基本的结构
int main(int argc,char *agrv[])

2 基本的输入输出
include <iostream>
using namespace std;
cin>>
cout<<

3 循环输入输出
while (!cin.eof())

4 结构问题
main里面如果要调用别的函数的话,
法一:把函数写在前面
法二:在main函数之前申明函数

5 移位问题
a<<1; 并不改变a的值。

*********************************************

2008-1-16

 1 int转换成字符串
#include <sstream>

stringstream ss;
ss << num;
const char *cString = ss.str( ).c_str( );

2 定义数组类型
typedef int sheet[2][2];

sheet a;

a[0][1] = 10;

***************************

2008-1-17

1 字符串
string 可以总结使用
getline(cin,string)
string::find()
string::substr()
string::c_str()
string::length()

char *str = new char[n]
cin>>str;
要new了之后才能用

***************************************

2008-1-18

1.enum a
{ ,//,号分割
   //最后一个不加,
}

*******************************************

2008-1-21

1 当指针遇上数组
用指针来指向数组中的某个元素。
int a[3] = {1,2,3};
int *temp = a+2;

把指针当参数 来指向数组中的某个元素
int *temp;
fun(temp);

void fun(int *&i){i = a+length;}
*& 顺序不能变

2 类结束了要";"

**********************************************

2008-1-22

1 遭遇指针数组
MyLink **link;
link = new MyLink[10]; //错误
link = new MyLink*[10];//正确

*************************************************

2008-1-24

1 error C2236: 意外的“class”。。。
enum后面,少个分号。

***************************************************

2008-7-25

关于struct结构

定义了一个struct结构.
struct _structure {int index;char* str} structure;
有一个链表数组,
structure a*;
先分配指定长度的东西,
a = malloc (sizeof(structure)*n);
然后就可以直接使用了?
a[0].index = 1;
a[0].str



指向指针的指针
int   **ptr;  
ptr   =   (int   **)malloc(sizeof(int   *)   *   10);  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值