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);